﻿namespace UnityEditor
{
    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using UnityEditorInternal;
    using UnityEngine;

    public sealed class EditorGUI
    {
        [CompilerGenerated]
        private static Func<string, string> <>f__am$cache58;
        [CompilerGenerated]
        private static Func<string, string> <>f__am$cache59;
        [CompilerGenerated]
        private static Func<string, string> <>f__am$cache5A;
        [CompilerGenerated]
        private static Func<string, string> <>f__am$cache5B;
        [CompilerGenerated]
        private static Dictionary<string, int> <>f__switch$map10;
        [CompilerGenerated]
        private static Dictionary<string, int> <>f__switch$mapC;
        [CompilerGenerated]
        private static Dictionary<string, int> <>f__switch$mapD;
        [CompilerGenerated]
        private static Dictionary<string, int> <>f__switch$mapE;
        [CompilerGenerated]
        private static Dictionary<string, int> <>f__switch$mapF;
        private static RecycledTextEditor activeEditor;
        private static bool bKeyEventActive = false;
        internal static Color kCurveBGColor = new Color(0.337f, 0.337f, 0.337f, 1f);
        internal static Color kCurveColor = Color.green;
        private static float kDragDeadzone = 16f;
        private const float kDragSensitivity = 0.03f;
        internal static string kFloatFieldFormatString = "g7";
        private const double kFoldoutExpandTimeout = 0.7;
        private const float kIndentPerControlLevel = 9f;
        private const float kIndentPerLevel = 15f;
        private const int kInspTitlebarIconWidth = 0x10;
        private const int kInspTitlebarSpacing = 2;
        private const int kInspTitlebarToggleWidth = 0x10;
        internal static string kIntFieldFormatString = "#######0";
        internal const float kLabelW = 80f;
        internal const float kMiniLabelW = 18f;
        internal static float kNumberW = 40f;
        internal const float kRectLabelW = 18f;
        internal const float kSingleLineHeight = 16f;
        internal const float kSliderMaxW = 100f;
        internal const float kSliderMinW = 60f;
        internal const float kSpacing = 5f;
        internal const float kStructHeaderLineHeight = 19f;
        internal static int lastControlID = 0;
        internal static int ms_IndentLevel = 0;
        private static int s_ArraySizeFieldHash = "ArraySizeField".GetHashCode();
        private static int s_ButtonMouseDownHash = "ButtonMouseDown".GetHashCode();
        private static Stack<bool> s_ChangedStack = new Stack<bool>();
        internal static bool s_CollectingToolTips;
        private static int s_ColorHash = "s_ColorHash".GetHashCode();
        private static int s_ColorPickID;
        private static int s_CurveHash = "s_CurveHash".GetHashCode();
        private static int s_CurveID;
        internal static DelayedTextEditor s_DelayedTextEditor = new DelayedTextEditor();
        private static int s_DelayedTextFieldHash = "DelayedEditorTextField".GetHashCode();
        private static int s_DragCandidateState = 0;
        internal static bool s_Dragged = false;
        private static float s_DragSensitivity = 0f;
        private static int s_DragStartIntValue = 0;
        private static Vector2 s_DragStartPos;
        private static float s_DragStartValue = 0f;
        internal static bool s_DragToPosition = true;
        private static int s_DragUpdatedOverID = 0;
        private static Stack<bool> s_EnabledStack = new Stack<bool>();
        private static int s_EnumField = "s_EnumField".GetHashCode();
        private static int s_FloatFieldHash = "EditorTextField".GetHashCode();
        private static double s_FoldoutDestTime;
        private static int s_FoldoutHash = "Foldout".GetHashCode();
        private static int s_GenericField = "s_GenericField".GetHashCode();
        private static readonly int s_GradientHash = "s_GradientHash".GetHashCode();
        private static int s_GradientID;
        internal static GUIContent s_HelpIcon;
        private static Texture2D s_HorizontalVUTexture;
        private static GUIContent s_IconDropDown;
        private static Material s_IconTextureInactive;
        private static int s_KeyEventFieldHash = "KeyEventField".GetHashCode();
        private static int s_LastThickness;
        private static int s_LayerMaskField = "s_LayerMaskField".GetHashCode();
        private static int s_MaskField = "s_MaskField".GetHashCode();
        private static int s_MinMaxSliderHash = "MinMaxSlider".GetHashCode();
        private static GUIContent s_MixedValueContent = new GUIContent("—", "Mixed Values");
        private static Color s_MixedValueContentColor = new Color(1f, 1f, 1f, 0.5f);
        private static Color s_MixedValueContentColorTemp = Color.white;
        private static int s_MouseDeltaReaderHash = "MouseDeltaReader".GetHashCode();
        private static Vector2 s_MouseDeltaReaderLastPos;
        private static int s_ObjectFieldHash = "s_ObjectFieldHash".GetHashCode();
        internal static string s_OriginalText = string.Empty;
        private static int s_PasswordFieldHash = "PasswordField".GetHashCode();
        private static int s_PopupHash = "EditorPopup".GetHashCode();
        internal static bool s_PostPoneMove = false;
        private static int s_PPtrHash = "s_PPtrHash".GetHashCode();
        private static int s_ProgressBarHash = "s_ProgressBarHash".GetHashCode();
        private static GUIContent s_PropertyFieldTempContent = new GUIContent();
        private static Stack<PropertyGUIData> s_PropertyStack = new Stack<PropertyGUIData>();
        internal static float s_RecycledCurrentEditingFloat;
        internal static int s_RecycledCurrentEditingInt;
        internal static string s_RecycledCurrentEditingString;
        internal static RecycledTextEditor s_RecycledEditor = new RecycledTextEditor();
        private static int s_SearchFieldHash = "EditorSearchField".GetHashCode();
        private static int s_SelectableLabelHash = "s_SelectableLabel".GetHashCode();
        internal static bool s_SelectAllOnMouseUp = true;
        private static bool s_ShowMixedValue;
        private static int s_SliderHash = "EditorSlider".GetHashCode();
        private static int s_TagFieldHash = "s_TagFieldHash".GetHashCode();
        private static int s_TextAreaHash = "EditorTextField".GetHashCode();
        private static int s_TextFieldHash = "EditorTextField".GetHashCode();
        private static Texture2D s_Texture;
        private static int s_TitlebarHash = "GenericTitlebar".GetHashCode();
        internal static GUIContent s_TitleSettingsIcon;
        private static int s_ToggleHash = "s_ToggleHash".GetHashCode();
        private static float[] s_Vector2Floats = new float[2];
        private static float[] s_Vector3Floats = new float[3];
        private static float[] s_Vector4Floats = new float[4];
        private static Texture2D s_VerticalVUTexture;
        private static bool s_WasBoldDefaultFont;
        private static GUIContent[] s_WHLabels = new GUIContent[] { new GUIContent("W"), new GUIContent("H") };
        private static GUIContent[] s_XYLabels = new GUIContent[] { new GUIContent("X"), new GUIContent("Y") };
        private static GUIContent[] s_XYZLabels = new GUIContent[] { new GUIContent("X"), new GUIContent("Y"), new GUIContent("Z") };
        private static GUIContent[] s_XYZWLabels = new GUIContent[] { new GUIContent("X"), new GUIContent("Y"), new GUIContent("Z"), new GUIContent("W") };
        private static Material tmp;
        private const float VU_SPLIT = 0.9f;

        internal static int ArraySizeField(Rect position, int id, int value, GUIStyle style)
        {
            BeginChangeCheck();
            string s = DelayedTextField(position, id, value.ToString(kIntFieldFormatString), "0123456789-", style);
            if (EndChangeCheck())
            {
                try
                {
                    value = int.Parse(s, CultureInfo.InvariantCulture.NumberFormat);
                }
                catch (FormatException)
                {
                }
            }
            return value;
        }

        internal static int ArraySizeField(Rect position, GUIContent label, int value, GUIStyle style)
        {
            int id = GetControlID(s_ArraySizeFieldHash, FocusType.Keyboard, position);
            return ArraySizeField(PrefixLabel(position, id, label), id, value, style);
        }

        public static void BeginChangeCheck()
        {
            s_ChangedStack.Push(GUI.changed);
            GUI.changed = false;
        }

        internal static void BeginCollectTooltips()
        {
            isCollectingTooltips = true;
        }

        public static void BeginDisabledGroup(bool disabled)
        {
            s_EnabledStack.Push(GUI.enabled);
            GUI.enabled &= !disabled;
        }

        internal static void BeginHandleMixedValueContentColor()
        {
            s_MixedValueContentColorTemp = GUI.contentColor;
            GUI.contentColor = !showMixedValue ? GUI.contentColor : (GUI.contentColor * s_MixedValueContentColor);
        }

        public static GUIContent BeginProperty(Rect totalPosition, GUIContent label, SerializedProperty property)
        {
            if (property == null)
            {
                string message = ((label != null) ? (label.text + ": ") : string.Empty) + "SerializedProperty is null";
                HelpBox(totalPosition, "null", MessageType.Error);
                throw new NullReferenceException(message);
            }
            s_PropertyFieldTempContent.text = (label != null) ? label.text : property.displayName;
            s_PropertyFieldTempContent.tooltip = !isCollectingTooltips ? null : ((label != null) ? label.tooltip : property.tooltip);
            s_PropertyFieldTempContent.image = (label != null) ? label.image : null;
            bool boldDefaultFont = EditorGUIUtility.GetBoldDefaultFont();
            if ((property.serializedObject.targetObjects.Length == 1) && property.isInstantiatedPrefab)
            {
                EditorGUIUtility.SetBoldDefaultFont(property.prefabOverride);
            }
            s_PropertyStack.Push(new PropertyGUIData(property, totalPosition, boldDefaultFont, GUI.enabled));
            showMixedValue = property.hasMultipleDifferentValues;
            GUI.enabled &= property.editable;
            return s_PropertyFieldTempContent;
        }

        public static Bounds BoundsField(Rect position, Bounds value)
        {
            position = DrawBoundsFieldLabelsAndAdjustPositionForValues(position);
            value.center = Vector3Field(position, value.center);
            position.y += 16f;
            value.extents = Vector3Field(position, value.extents);
            return value;
        }

        private static void BoundsField(Rect position, SerializedProperty property, GUIContent label)
        {
            int num = ms_IndentLevel;
            if (LabelHasContent(label))
            {
                GUI.Label(IndentedRect(position), label, EditorStyles.label);
                position.y += 19f;
                ms_IndentLevel++;
            }
            position.height = 16f;
            position = DrawBoundsFieldLabelsAndAdjustPositionForValues(position);
            SerializedProperty valuesIterator = property.Copy();
            valuesIterator.NextVisible(true);
            valuesIterator.NextVisible(true);
            MultiField(position, s_XYZLabels, valuesIterator);
            valuesIterator.NextVisible(true);
            position.y += 16f;
            MultiField(position, s_XYZLabels, valuesIterator);
            ms_IndentLevel = num;
        }

        public static Bounds BoundsField(Rect position, GUIContent label, Bounds value)
        {
            int num = ms_IndentLevel;
            if (LabelHasContent(label))
            {
                GUI.Label(IndentedRect(position), label, EditorStyles.label);
                position.y += 16f;
                ms_IndentLevel++;
            }
            value = BoundsField(position, value);
            ms_IndentLevel = num;
            return value;
        }

        internal static bool ButtonMouseDown(Rect position, GUIContent content, FocusType fType, GUIStyle style)
        {
            int controlID = GetControlID(s_ButtonMouseDownHash, fType, position);
            Event current = Event.current;
            EventType type = current.type;
            switch (type)
            {
                case EventType.KeyDown:
                    if ((GUIUtility.keyboardControl != controlID) || (current.character != ' '))
                    {
                        break;
                    }
                    Event.current.Use();
                    return true;

                case EventType.Repaint:
                    if (!showMixedValue)
                    {
                        style.Draw(position, content, controlID, false);
                    }
                    else
                    {
                        BeginHandleMixedValueContentColor();
                        style.Draw(position, s_MixedValueContent, controlID, false);
                        EndHandleMixedValueContentColor();
                    }
                    break;

                default:
                    if ((type == EventType.MouseDown) && (position.Contains(current.mousePosition) && (current.button == 0)))
                    {
                        Event.current.Use();
                        return true;
                    }
                    break;
            }
            return false;
        }

        private static float CalculateFloatDragSensitivity(float value)
        {
            if (!float.IsInfinity(value) && !float.IsNaN(value))
            {
                return (Mathf.Max(1f, Mathf.Pow(Mathf.Abs(value), 0.5f)) * 0.03f);
            }
            return 0f;
        }

        private static float CalculateIntDragSensitivity(int value)
        {
            return Mathf.Max((float) 1f, (float) (Mathf.Pow(Mathf.Abs((float) value), 0.5f) * 0.03f));
        }

        internal static void ClearStacks()
        {
            s_EnabledStack.Clear();
            s_ChangedStack.Clear();
            s_PropertyStack.Clear();
        }

        public static Color ColorField(Rect position, Color value)
        {
            int id = GetControlID(s_ColorHash, EditorGUIUtility.native, position);
            return DoColorField(IndentedRect(position), id, value, true, true);
        }

        public static Color ColorField(Rect position, string label, Color value)
        {
            return ColorField(position, EditorGUIUtility.TempContent(label), value);
        }

        public static Color ColorField(Rect position, GUIContent label, Color value)
        {
            int id = GetControlID(s_ColorHash, EditorGUIUtility.native, position);
            return DoColorField(PrefixLabel(position, id, label), id, value, true, true);
        }

        internal static Color ColorField(Rect position, Color value, bool showEyedropper, bool showAlpha)
        {
            int id = GetControlID(s_ColorHash, EditorGUIUtility.native, position);
            return DoColorField(position, id, value, showEyedropper, showAlpha);
        }

        internal static Color ColorField(Rect position, GUIContent label, Color value, bool showEyedropper, bool showAlpha)
        {
            int id = GetControlID(s_ColorHash, EditorGUIUtility.native, position);
            return DoColorField(PrefixLabel(position, id, label), id, value, showEyedropper, showAlpha);
        }

        public static AnimationCurve CurveField(Rect position, AnimationCurve value)
        {
            int id = GetControlID(s_CurveHash, EditorGUIUtility.native, position);
            return DoCurveField(IndentedRect(position), id, value, kCurveColor, new Rect(), null);
        }

        public static AnimationCurve CurveField(Rect position, string label, AnimationCurve value)
        {
            return CurveField(position, EditorGUIUtility.TempContent(label), value);
        }

        public static AnimationCurve CurveField(Rect position, GUIContent label, AnimationCurve value)
        {
            int id = GetControlID(s_CurveHash, EditorGUIUtility.native, position);
            return DoCurveField(PrefixLabel(position, id, label), id, value, kCurveColor, new Rect(), null);
        }

        public static void CurveField(Rect position, SerializedProperty value, Color color, Rect ranges)
        {
            int id = GetControlID(s_CurveHash, EditorGUIUtility.native, position);
            DoCurveField(position, id, null, color, ranges, value);
        }

        public static AnimationCurve CurveField(Rect position, AnimationCurve value, Color color, Rect ranges)
        {
            int id = GetControlID(s_CurveHash, EditorGUIUtility.native, position);
            return DoCurveField(IndentedRect(position), id, value, color, ranges, null);
        }

        public static AnimationCurve CurveField(Rect position, string label, AnimationCurve value, Color color, Rect ranges)
        {
            return CurveField(position, EditorGUIUtility.TempContent(label), value, color, ranges);
        }

        public static AnimationCurve CurveField(Rect position, GUIContent label, AnimationCurve value, Color color, Rect ranges)
        {
            int id = GetControlID(s_CurveHash, EditorGUIUtility.native, position);
            return DoCurveField(PrefixLabel(position, id, label), id, value, color, ranges, null);
        }

        internal static int CycleButton(Rect position, int selected, GUIContent[] options, GUIStyle style)
        {
            if ((selected >= options.Length) || (selected < 0))
            {
                selected = 0;
                GUI.changed = true;
            }
            if (GUI.Button(position, options[selected], style))
            {
                selected++;
                GUI.changed = true;
                if (selected >= options.Length)
                {
                    selected = 0;
                }
            }
            return selected;
        }

        internal static string DelayedTextField(Rect position, string value, string allowedLetters, GUIStyle style)
        {
            int id = GetControlID(s_DelayedTextFieldHash, FocusType.Keyboard, position);
            return DelayedTextField(position, id, value, allowedLetters, style);
        }

        internal static string DelayedTextField(Rect position, int id, string value, string allowedLetters, GUIStyle style)
        {
            string str;
            bool flag;
            if (GUIUtility.keyboardControl == id)
            {
                if (!s_DelayedTextEditor.IsEditingControl(id))
                {
                    str = s_RecycledCurrentEditingString = value;
                }
                else
                {
                    str = s_RecycledCurrentEditingString;
                }
                Event current = Event.current;
                if ((current.type == EventType.ValidateCommand) && (current.commandName == "UndoRedoPerformed"))
                {
                    str = value;
                }
            }
            else
            {
                str = value;
            }
            bool changed = GUI.changed;
            str = s_DelayedTextEditor.OnGUI(id, str, out flag);
            GUI.changed = false;
            if (!flag)
            {
                str = DoTextField(s_DelayedTextEditor, id, position, str, style, allowedLetters, out flag, false, false, false);
                GUI.changed = false;
                if (GUIUtility.keyboardControl == id)
                {
                    if (!s_DelayedTextEditor.IsEditingControl(id))
                    {
                        if (value != str)
                        {
                            GUI.changed = true;
                            value = str;
                        }
                    }
                    else
                    {
                        s_RecycledCurrentEditingString = str;
                    }
                }
            }
            else
            {
                GUI.changed = true;
                value = str;
            }
            GUI.changed |= changed;
            return value;
        }

        private static Color DoColorField(Rect position, int id, Color value, bool showEyedropper, bool showAlpha)
        {
            Event current = Event.current;
            GUIStyle colorField = EditorStyles.colorField;
            Color color = value;
            value = !showMixedValue ? value : Color.white;
            EventType typeForControl = current.GetTypeForControl(id);
            switch (typeForControl)
            {
                case EventType.KeyDown:
                    if ((GUIUtility.keyboardControl == id) && (((current.keyCode == KeyCode.Space) || (current.keyCode == KeyCode.Return)) || (current.keyCode == KeyCode.KeypadEnter)))
                    {
                        Event.current.Use();
                        showMixedValue = false;
                        ColorPicker.Show(GUIView.current, value, showAlpha);
                        GUIUtility.ExitGUI();
                    }
                    return color;

                case EventType.Repaint:
                    Rect rect;
                    if (!showEyedropper)
                    {
                        rect = position;
                    }
                    else
                    {
                        rect = colorField.padding.Remove(position);
                    }
                    if (showEyedropper && (s_ColorPickID == id))
                    {
                        Color pickedColor = EyeDropper.GetPickedColor();
                        pickedColor.a = value.a;
                        EditorGUIUtility.DrawColorSwatch(rect, pickedColor, showAlpha);
                    }
                    else
                    {
                        EditorGUIUtility.DrawColorSwatch(rect, value, showAlpha);
                    }
                    if (showEyedropper)
                    {
                        colorField.Draw(position, GUIContent.none, id);
                        return color;
                    }
                    EditorStyles.colorPickerBox.Draw(position, GUIContent.none, id);
                    return color;
            }
            if (typeForControl != EventType.MouseDown)
            {
                if ((typeForControl == EventType.ExecuteCommand) && (GUIUtility.keyboardControl == id))
                {
                    int num;
                    string commandName = current.commandName;
                    if (commandName == null)
                    {
                        return color;
                    }
                    if (<>f__switch$mapF == null)
                    {
                        Dictionary<string, int> dictionary = new Dictionary<string, int>(4);
                        dictionary.Add("EyeDropperUpdate", 0);
                        dictionary.Add("EyeDropperClicked", 1);
                        dictionary.Add("EyeDropperCancelled", 2);
                        dictionary.Add("ColorPickerChanged", 3);
                        <>f__switch$mapF = dictionary;
                    }
                    if (!<>f__switch$mapF.TryGetValue(commandName, out num))
                    {
                        return color;
                    }
                    switch (num)
                    {
                        case 0:
                            HandleUtility.Repaint();
                            return color;

                        case 1:
                        {
                            GUI.changed = true;
                            HandleUtility.Repaint();
                            Color lastPickedColor = EyeDropper.GetLastPickedColor();
                            lastPickedColor.a = value.a;
                            s_ColorPickID = 0;
                            return lastPickedColor;
                        }
                        case 2:
                            HandleUtility.Repaint();
                            s_ColorPickID = 0;
                            return color;

                        case 3:
                            GUI.changed = true;
                            HandleUtility.Repaint();
                            return ColorPicker.color;
                    }
                }
                return color;
            }
            if (showEyedropper)
            {
                position.width -= 20f;
            }
            if (position.Contains(current.mousePosition))
            {
                GUIUtility.keyboardControl = id;
                showMixedValue = false;
                ColorPicker.Show(GUIView.current, value, showAlpha);
                GUIUtility.ExitGUI();
            }
            if (showEyedropper)
            {
                position.width += 20f;
                if (position.Contains(current.mousePosition))
                {
                    GUIUtility.keyboardControl = id;
                    EyeDropper.Start(GUIView.current);
                    s_ColorPickID = id;
                    GUIUtility.ExitGUI();
                }
            }
            return color;
        }

        private static AnimationCurve DoCurveField(Rect position, int id, AnimationCurve value, Color color, Rect ranges, SerializedProperty property)
        {
            Event current = Event.current;
            position.width = Mathf.Max(position.width, 2f);
            position.height = Mathf.Max(position.height, 2f);
            if ((GUIUtility.keyboardControl == id) && (Event.current.type != EventType.Layout))
            {
                if (s_CurveID != id)
                {
                    s_CurveID = id;
                    if (CurveEditorWindow.visible)
                    {
                        SetCurveEditorWindowCurve(value, property, color);
                        ShowCurvePopup(GUIView.current, ranges);
                    }
                }
                else if (CurveEditorWindow.visible && (Event.current.type == EventType.Repaint))
                {
                    SetCurveEditorWindowCurve(value, property, color);
                    CurveEditorWindow.instance.Repaint();
                }
            }
            EventType typeForControl = current.GetTypeForControl(id);
            switch (typeForControl)
            {
                case EventType.KeyDown:
                    if ((GUIUtility.keyboardControl == id) && (((current.keyCode == KeyCode.Space) || (current.keyCode == KeyCode.Return)) || (current.keyCode == KeyCode.KeypadEnter)))
                    {
                        s_CurveID = id;
                        SetCurveEditorWindowCurve(value, property, color);
                        ShowCurvePopup(GUIView.current, ranges);
                        current.Use();
                        GUIUtility.ExitGUI();
                    }
                    return value;

                case EventType.Repaint:
                {
                    Rect rect = position;
                    rect.y++;
                    rect.height--;
                    if (!(ranges != new Rect()))
                    {
                        EditorGUIUtility.DrawCurveSwatch(rect, value, property, color, kCurveBGColor);
                        return value;
                    }
                    EditorGUIUtility.DrawCurveSwatch(rect, value, property, color, kCurveBGColor, ranges);
                    return value;
                }
            }
            if (typeForControl != EventType.MouseDown)
            {
                int num;
                if (typeForControl != EventType.ExecuteCommand)
                {
                    return value;
                }
                if (s_CurveID != id)
                {
                    return value;
                }
                string commandName = current.commandName;
                if (commandName == null)
                {
                    return value;
                }
                if (<>f__switch$map10 == null)
                {
                    Dictionary<string, int> dictionary = new Dictionary<string, int>(1);
                    dictionary.Add("CurveChanged", 0);
                    <>f__switch$map10 = dictionary;
                }
                if (!<>f__switch$map10.TryGetValue(commandName, out num))
                {
                    return value;
                }
                if (num != 0)
                {
                    return value;
                }
                GUI.changed = true;
                AnimationCurvePreviewCache.ClearCache();
                HandleUtility.Repaint();
                if (property != null)
                {
                    property.animationCurveValue = CurveEditorWindow.curve;
                    if (property.hasMultipleDifferentValues)
                    {
                        Debug.LogError("AnimationCurve SerializedProperty hasMultipleDifferentValues is true after writing.");
                    }
                }
                return CurveEditorWindow.curve;
            }
            if (position.Contains(current.mousePosition))
            {
                s_CurveID = id;
                GUIUtility.keyboardControl = id;
                SetCurveEditorWindowCurve(value, property, color);
                ShowCurvePopup(GUIView.current, ranges);
                current.Use();
                GUIUtility.ExitGUI();
            }
            return value;
        }

        internal static UnityEngine.Object DoDropField(Rect position, int id, System.Type objType, ObjectFieldValidator validator, bool allowSceneObjects, GUIStyle style)
        {
            if (validator == null)
            {
                validator = new ObjectFieldValidator(EditorGUI.ValidateObjectFieldAssignment);
            }
            EventType rawType = Event.current.type;
            if ((!GUI.enabled && GUIClip.enabled) && (Event.current.rawType == EventType.MouseDown))
            {
                rawType = Event.current.rawType;
            }
            EventType type2 = rawType;
            switch (type2)
            {
                case EventType.Repaint:
                    style.Draw(position, GUIContent.none, id, DragAndDrop.activeControlID == id);
                    break;

                case EventType.DragUpdated:
                case EventType.DragPerform:
                {
                    if (!position.Contains(Event.current.mousePosition) || !GUI.enabled)
                    {
                        break;
                    }
                    UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
                    UnityEngine.Object target = validator(objectReferences, objType, null);
                    if (((target != null) && !allowSceneObjects) && !EditorUtility.IsPersistent(target))
                    {
                        target = null;
                    }
                    if (target == null)
                    {
                        break;
                    }
                    DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
                    if (rawType != EventType.DragPerform)
                    {
                        DragAndDrop.activeControlID = id;
                        Event.current.Use();
                        break;
                    }
                    if (target != null)
                    {
                        Analytics.Event("ObjectSelection", "DragAndDrop", !EditorUtility.IsPersistent(target) ? "Scene" : "Asset", 1);
                    }
                    else
                    {
                        Analytics.Event("ObjectSelection", "DragAndDrop", "null", 1);
                    }
                    GUI.changed = true;
                    DragAndDrop.AcceptDrag();
                    DragAndDrop.activeControlID = 0;
                    Event.current.Use();
                    return target;
                }
                default:
                    if ((type2 == EventType.DragExited) && GUI.enabled)
                    {
                        HandleUtility.Repaint();
                    }
                    break;
            }
            return null;
        }

        internal static void DoDropShadowLabel(Rect position, GUIContent content, GUIStyle style, float shadowOpa)
        {
            if (Event.current.type == EventType.Repaint)
            {
                DrawLabelShadow(position, content, style, shadowOpa);
                style.Draw(position, content, false, false, false, false);
            }
        }

        internal static float DoFloatField(RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, float value, string formatString, GUIStyle style, bool draggable)
        {
            return DoFloatField(editor, position, dragHotZone, id, value, formatString, style, draggable, (Event.current.GetTypeForControl(id) != EventType.MouseDown) ? 0f : CalculateFloatDragSensitivity(s_DragStartValue));
        }

        internal static float DoFloatField(RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, float value, string formatString, GUIStyle style, bool draggable, float dragSensitivity)
        {
            int intVal = 0;
            DoNumberField(editor, position, dragHotZone, id, true, ref value, ref intVal, formatString, style, draggable, dragSensitivity);
            return value;
        }

        internal static Gradient DoGradientField(Rect position, int id, Gradient value, SerializedProperty property)
        {
            Event current = Event.current;
            EventType typeForControl = current.GetTypeForControl(id);
            switch (typeForControl)
            {
                case EventType.KeyDown:
                    if ((GUIUtility.keyboardControl == id) && (((current.keyCode == KeyCode.Space) || (current.keyCode == KeyCode.Return)) || (current.keyCode == KeyCode.KeypadEnter)))
                    {
                        Event.current.Use();
                        Gradient newGradient = (property == null) ? value : property.gradientValue;
                        GradientPicker.Show(newGradient);
                        GUIUtility.ExitGUI();
                    }
                    return value;

                case EventType.Repaint:
                {
                    Rect rect = new Rect(position.x + 1f, position.y + 1f, position.width - 2f, position.height - 2f);
                    if (property == null)
                    {
                        GradientEditor.DrawGradientSwatch(rect, value, Color.white);
                    }
                    else
                    {
                        GradientEditor.DrawGradientSwatch(rect, property, Color.white);
                    }
                    EditorStyles.colorPickerBox.Draw(position, GUIContent.none, id);
                    return value;
                }
            }
            if (typeForControl != EventType.MouseDown)
            {
                int num;
                if (typeForControl != EventType.ExecuteCommand)
                {
                    return value;
                }
                if (s_GradientID != id)
                {
                    return value;
                }
                string commandName = current.commandName;
                if (commandName == null)
                {
                    return value;
                }
                if (<>f__switch$mapC == null)
                {
                    Dictionary<string, int> dictionary = new Dictionary<string, int>(1);
                    dictionary.Add("GradientPickerChanged", 0);
                    <>f__switch$mapC = dictionary;
                }
                if (!<>f__switch$mapC.TryGetValue(commandName, out num))
                {
                    return value;
                }
                if (num != 0)
                {
                    return value;
                }
                GUI.changed = true;
                GradientPreviewCache.ClearCache();
                HandleUtility.Repaint();
                if (property != null)
                {
                    property.gradientValue = GradientPicker.gradient;
                }
                return GradientPicker.gradient;
            }
            if (position.Contains(current.mousePosition))
            {
                if (current.button == 0)
                {
                    s_GradientID = id;
                    GUIUtility.keyboardControl = id;
                    Gradient gradient = (property == null) ? value : property.gradientValue;
                    GradientPicker.Show(gradient);
                    GUIUtility.ExitGUI();
                    return value;
                }
                if ((current.button != 1) || (property == null))
                {
                    return value;
                }
                GradientContextMenu.Show(property);
            }
            return value;
        }

        internal static int DoIntField(RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, int value, string formatString, GUIStyle style, bool draggable, float dragSensitivity)
        {
            float floatVal = 0f;
            DoNumberField(editor, position, dragHotZone, id, false, ref floatVal, ref value, formatString, style, draggable, dragSensitivity);
            return value;
        }

        internal static Event DoKeyEventField(Rect position, Event _event, GUIStyle style)
        {
            int controlID = GUIUtility.GetControlID(s_KeyEventFieldHash, FocusType.Native, position);
            Event current = Event.current;
            switch (current.GetTypeForControl(controlID))
            {
                case EventType.MouseDown:
                    if (position.Contains(current.mousePosition))
                    {
                        GUIUtility.hotControl = controlID;
                        current.Use();
                        if (!bKeyEventActive)
                        {
                            bKeyEventActive = true;
                            return _event;
                        }
                        bKeyEventActive = false;
                    }
                    return _event;

                case EventType.MouseUp:
                    if (GUIUtility.hotControl == controlID)
                    {
                        GUIUtility.hotControl = controlID;
                        current.Use();
                    }
                    return _event;

                case EventType.MouseMove:
                case EventType.KeyUp:
                case EventType.ScrollWheel:
                    return _event;

                case EventType.MouseDrag:
                    if (GUIUtility.hotControl == controlID)
                    {
                        current.Use();
                    }
                    return _event;

                case EventType.KeyDown:
                    if ((GUIUtility.hotControl == controlID) && bKeyEventActive)
                    {
                        if (current.character != '\0')
                        {
                            break;
                        }
                        if (current.alt && (((current.keyCode == KeyCode.AltGr) || (current.keyCode == KeyCode.LeftAlt)) || (current.keyCode == KeyCode.RightAlt)))
                        {
                            return _event;
                        }
                        if (current.control && ((current.keyCode == KeyCode.LeftControl) || (current.keyCode == KeyCode.RightControl)))
                        {
                            return _event;
                        }
                        if (current.command && (((current.keyCode == KeyCode.LeftCommand) || (current.keyCode == KeyCode.RightCommand)) || ((current.keyCode == KeyCode.LeftWindows) || (current.keyCode == KeyCode.RightWindows))))
                        {
                            return _event;
                        }
                        if (!current.shift || (((current.keyCode != KeyCode.LeftShift) && (current.keyCode != KeyCode.RightShift)) && (current.keyCode != KeyCode.None)))
                        {
                            break;
                        }
                    }
                    return _event;

                case EventType.Repaint:
                {
                    if (!bKeyEventActive)
                    {
                        string t = InternalEditorUtility.TextifyEvent(_event);
                        style.Draw(position, EditorGUIUtility.TempContent(t), controlID);
                        return _event;
                    }
                    GUIContent content = EditorGUIUtility.TempContent("[Please press a key]");
                    style.Draw(position, content, controlID);
                    return _event;
                }
                default:
                    return _event;
            }
            bKeyEventActive = false;
            GUI.changed = true;
            GUIUtility.hotControl = 0;
            Event event3 = new Event(current);
            current.Use();
            return event3;
        }

        private static void DoMinMaxSlider(Rect position, int id, ref float minValue, ref float maxValue, float minLimit, float maxLimit)
        {
            float size = maxValue - minValue;
            BeginChangeCheck();
            Rect rect = position;
            EditorGUIExt.DoMinMaxSlider(rect, id, ref minValue, ref size, minLimit, maxLimit, minLimit, maxLimit, GUI.skin.horizontalSlider, EditorStyles.minMaxHorizontalSliderThumb, true);
            if (EndChangeCheck())
            {
                maxValue = minValue + size;
            }
        }

        internal static void DoNumberField(RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, bool isFloat, ref float floatVal, ref int intVal, string formatString, GUIStyle style, bool draggable, float dragSensitivity)
        {
            bool flag;
            string str2;
            string allowedletters = !isFloat ? "0123456789-" : "inftynaeINFTYNAE0123456789.,-";
            if (draggable)
            {
                DragNumberValue(editor, position, dragHotZone, id, isFloat, ref floatVal, ref intVal, formatString, style, dragSensitivity);
            }
            Event current = Event.current;
            if ((GUIUtility.keyboardControl == id) || (((current.type == EventType.MouseDown) && (current.button == 0)) && position.Contains(current.mousePosition)))
            {
                if (!editor.IsEditingControl(id))
                {
                    str2 = s_RecycledCurrentEditingString = !isFloat ? ((int) intVal).ToString(formatString) : ((float) floatVal).ToString(formatString);
                }
                else
                {
                    str2 = s_RecycledCurrentEditingString;
                    if ((current.type == EventType.ValidateCommand) && (current.commandName == "UndoRedoPerformed"))
                    {
                        str2 = !isFloat ? ((int) intVal).ToString(formatString) : ((float) floatVal).ToString(formatString);
                    }
                }
            }
            else
            {
                str2 = !isFloat ? ((int) intVal).ToString(formatString) : ((float) floatVal).ToString(formatString);
            }
            if (GUIUtility.keyboardControl == id)
            {
                str2 = DoTextField(editor, id, position, str2, style, allowedletters, out flag, false, false, false);
                if (flag)
                {
                    GUI.changed = true;
                    s_RecycledCurrentEditingString = str2;
                    if (isFloat)
                    {
                        switch (str2.ToLower())
                        {
                            case "inf":
                            case "infinity":
                                floatVal = float.PositiveInfinity;
                                return;

                            case "-inf":
                            case "-infinity":
                                floatVal = float.NegativeInfinity;
                                return;
                        }
                        if (!float.TryParse(str2.Replace(',', '.'), NumberStyles.Float, (IFormatProvider) CultureInfo.InvariantCulture.NumberFormat, out floatVal))
                        {
                            floatVal = s_RecycledCurrentEditingFloat = 0f;
                        }
                        else
                        {
                            if (float.IsNaN(floatVal))
                            {
                                floatVal = 0f;
                            }
                            s_RecycledCurrentEditingFloat = floatVal;
                        }
                    }
                    else if (!int.TryParse(str2, out intVal))
                    {
                        intVal = s_RecycledCurrentEditingInt = 0;
                    }
                    else
                    {
                        s_RecycledCurrentEditingInt = intVal;
                    }
                }
            }
            else
            {
                str2 = DoTextField(editor, id, position, str2, style, allowedletters, out flag, false, false, false);
            }
        }

        internal static UnityEngine.Object DoObjectField(Rect position, Rect dropRect, int id, UnityEngine.Object obj, System.Type objType, SerializedProperty property, ObjectFieldValidator validator, bool allowSceneObjects)
        {
            return DoObjectField(position, dropRect, id, obj, objType, property, validator, allowSceneObjects, EditorStyles.objectField);
        }

        internal static UnityEngine.Object DoObjectField(Rect position, Rect dropRect, int id, UnityEngine.Object obj, System.Type objType, SerializedProperty property, ObjectFieldValidator validator, bool allowSceneObjects, GUIStyle style)
        {
            if (validator == null)
            {
                validator = new ObjectFieldValidator(EditorGUI.ValidateObjectFieldAssignment);
            }
            Event current = Event.current;
            EventType rawType = current.type;
            if ((!GUI.enabled && GUIClip.enabled) && (Event.current.rawType == EventType.MouseDown))
            {
                rawType = Event.current.rawType;
            }
            switch (rawType)
            {
                case EventType.KeyDown:
                    if ((GUIUtility.keyboardControl == id) && GUI.enabled)
                    {
                        if ((current.keyCode == KeyCode.Backspace) || (current.keyCode == KeyCode.Delete))
                        {
                            if (property != null)
                            {
                                property.objectReferenceValue = null;
                            }
                            else
                            {
                                obj = null;
                            }
                            GUI.changed = true;
                            Event.current.Use();
                        }
                        if (current.keyCode == KeyCode.Space)
                        {
                            ObjectSelector.get.Show(obj, objType, property, allowSceneObjects);
                            ObjectSelector.get.objectSelectorID = id;
                            current.Use();
                            GUIUtility.ExitGUI();
                        }
                    }
                    return obj;

                case EventType.Repaint:
                    GUIContent content;
                    if (!showMixedValue)
                    {
                        if (property != null)
                        {
                            content = EditorGUIUtility.TempContent(property.objectReferenceStringValue, AssetPreview.GetMiniThumbnail(property.objectReferenceValue));
                            obj = property.objectReferenceValue;
                            if (obj != null)
                            {
                                UnityEngine.Object[] references = new UnityEngine.Object[] { obj };
                                if (validator(references, objType, property) == null)
                                {
                                    content = EditorGUIUtility.TempContent("Type mismatch");
                                }
                            }
                        }
                        else
                        {
                            content = EditorGUIUtility.ObjectContent(obj, objType);
                        }
                    }
                    else
                    {
                        content = s_MixedValueContent;
                    }
                    if (!EditorGUIUtility.lookLikeInspector && EditorGUIUtility.HasObjectThumbnail(objType))
                    {
                        GUIStyle objectFieldThumb = EditorStyles.objectFieldThumb;
                        objectFieldThumb.Draw(position, GUIContent.none, id, DragAndDrop.activeControlID == id);
                        if ((obj != null) && !showMixedValue)
                        {
                            bool flag = obj is Cubemap;
                            Rect rect2 = objectFieldThumb.padding.Remove(position);
                            if (flag)
                            {
                                rect2.x += (rect2.width - content.image.width) / 2f;
                                rect2.y += (rect2.height - content.image.width) / 2f;
                                GUIStyle.none.Draw(rect2, content.image, false, false, false, false);
                            }
                            else
                            {
                                DrawPreviewTexture(rect2, content.image);
                            }
                        }
                        else
                        {
                            GUIStyle style3 = objectFieldThumb.name + "Overlay";
                            BeginHandleMixedValueContentColor();
                            style3.Draw(position, content, id);
                            EndHandleMixedValueContentColor();
                        }
                        (objectFieldThumb.name + "Overlay2").Draw(position, EditorGUIUtility.TempContent("Select"), id);
                        return obj;
                    }
                    BeginHandleMixedValueContentColor();
                    style.Draw(position, content, id, DragAndDrop.activeControlID == id);
                    EndHandleMixedValueContentColor();
                    return obj;

                case EventType.DragUpdated:
                case EventType.DragPerform:
                    if (dropRect.Contains(Event.current.mousePosition) && GUI.enabled)
                    {
                        UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
                        UnityEngine.Object target = validator(objectReferences, objType, property);
                        if (((target != null) && !allowSceneObjects) && !EditorUtility.IsPersistent(target))
                        {
                            target = null;
                        }
                        if (target == null)
                        {
                            return obj;
                        }
                        DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
                        if (rawType != EventType.DragPerform)
                        {
                            DragAndDrop.activeControlID = id;
                        }
                        else
                        {
                            if (property != null)
                            {
                                property.objectReferenceValue = target;
                            }
                            else
                            {
                                obj = target;
                            }
                            if (target != null)
                            {
                                Analytics.Event("ObjectSelection", "DragAndDrop", !EditorUtility.IsPersistent(target) ? "Scene" : "Asset", 1);
                            }
                            else
                            {
                                Analytics.Event("ObjectSelection", "DragAndDrop", "null", 1);
                            }
                            GUI.changed = true;
                            DragAndDrop.AcceptDrag();
                            DragAndDrop.activeControlID = 0;
                        }
                        Event.current.Use();
                    }
                    return obj;

                case EventType.ExecuteCommand:
                {
                    if ((!(current.commandName == "ObjectSelectorUpdated") || (ObjectSelector.get.objectSelectorID != id)) || (GUIUtility.keyboardControl != id))
                    {
                        return obj;
                    }
                    UnityEngine.Object[] objArray2 = new UnityEngine.Object[] { ObjectSelector.GetCurrentObject() };
                    UnityEngine.Object obj4 = validator(objArray2, objType, property);
                    if (property != null)
                    {
                        property.objectReferenceValue = obj4;
                    }
                    if (obj4 != null)
                    {
                        Analytics.Event("ObjectSelection", "ObjectPickerWindow", !EditorUtility.IsPersistent(obj4) ? "Scene" : "Asset", 1);
                    }
                    else
                    {
                        Analytics.Event("ObjectSelection", "ObjectPickerWindow", "null", 1);
                    }
                    GUI.changed = true;
                    current.Use();
                    return obj4;
                }
                case EventType.DragExited:
                    if (GUI.enabled)
                    {
                        HandleUtility.Repaint();
                    }
                    return obj;

                case EventType.MouseDown:
                    if (Event.current.button == 0)
                    {
                        Rect rect;
                        if (!position.Contains(Event.current.mousePosition))
                        {
                            return obj;
                        }
                        if (!EditorGUIUtility.lookLikeInspector && EditorGUIUtility.HasObjectThumbnail(objType))
                        {
                            rect = new Rect(position.xMax - 32f, position.yMax - 14f, 32f, 14f);
                        }
                        else
                        {
                            rect = new Rect(position.xMax - 15f, position.y, 15f, position.height);
                        }
                        RecycledTextEditor.s_ActuallyEditing = false;
                        if (rect.Contains(Event.current.mousePosition))
                        {
                            if (GUI.enabled)
                            {
                                GUIUtility.keyboardControl = id;
                                ObjectSelector.get.Show(obj, objType, property, allowSceneObjects);
                                ObjectSelector.get.objectSelectorID = id;
                                current.Use();
                                GUIUtility.ExitGUI();
                            }
                            return obj;
                        }
                        UnityEngine.Object gameObject = (property == null) ? obj : property.objectReferenceValue;
                        Component component = gameObject as Component;
                        if (component != null)
                        {
                            gameObject = component.gameObject;
                        }
                        if (showMixedValue)
                        {
                            gameObject = null;
                        }
                        if (Event.current.clickCount == 1)
                        {
                            GUIUtility.keyboardControl = id;
                            if (gameObject != null)
                            {
                                EditorGUIUtility.PingObject(gameObject);
                            }
                            current.Use();
                            return obj;
                        }
                        if (Event.current.clickCount == 2)
                        {
                            if (gameObject != null)
                            {
                                AssetDatabase.OpenAsset(gameObject);
                                GUIUtility.ExitGUI();
                            }
                            current.Use();
                        }
                    }
                    return obj;
            }
            return obj;
        }

        internal static bool DoObjectFoldout(int id, Rect position, UnityEngine.Object[] targetObjs, bool foldout)
        {
            bool enabled = GUI.enabled;
            GUI.enabled = true;
            Event current = Event.current;
            EventType typeForControl = current.GetTypeForControl(id);
            switch (typeForControl)
            {
                case EventType.MouseDown:
                    if (position.Contains(current.mousePosition))
                    {
                        if ((current.button != 1) || (targetObjs[0] == null))
                        {
                            if ((current.button == 0) && ((Application.platform != RuntimePlatform.OSXEditor) || !current.control))
                            {
                                GUIUtility.hotControl = id;
                                DragAndDropDelay stateObject = (DragAndDropDelay) GUIUtility.GetStateObject(typeof(DragAndDropDelay), id);
                                stateObject.mouseDownPosition = current.mousePosition;
                                current.Use();
                            }
                        }
                        else
                        {
                            EditorUtility.DisplayObjectContextMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), targetObjs, 0);
                            current.Use();
                        }
                    }
                    goto Label_02E7;

                case EventType.MouseUp:
                    if (GUIUtility.hotControl == id)
                    {
                        GUIUtility.hotControl = 0;
                        current.Use();
                        if (position.Contains(current.mousePosition))
                        {
                            GUI.changed = true;
                            foldout = !foldout;
                        }
                    }
                    goto Label_02E7;

                case EventType.MouseDrag:
                {
                    if (GUIUtility.hotControl != id)
                    {
                        goto Label_02E7;
                    }
                    DragAndDropDelay delay2 = (DragAndDropDelay) GUIUtility.GetStateObject(typeof(DragAndDropDelay), id);
                    if (delay2.CanStartDrag())
                    {
                        GUIUtility.hotControl = 0;
                        DragAndDrop.PrepareStartDrag();
                        DragAndDrop.objectReferences = targetObjs;
                        if (targetObjs.Length <= 1)
                        {
                            DragAndDrop.StartDrag(ObjectNames.GetDragAndDropTitle(targetObjs[0]));
                        }
                        else
                        {
                            DragAndDrop.StartDrag("<Multiple>");
                        }
                    }
                    break;
                }
                default:
                    switch (typeForControl)
                    {
                        case EventType.DragUpdated:
                            if (s_DragUpdatedOverID != id)
                            {
                                if (position.Contains(current.mousePosition))
                                {
                                    s_DragUpdatedOverID = id;
                                    s_FoldoutDestTime = Time.realtimeSinceStartup + 0.7;
                                }
                            }
                            else if (position.Contains(current.mousePosition))
                            {
                                if (Time.realtimeSinceStartup > s_FoldoutDestTime)
                                {
                                    foldout = true;
                                    HandleUtility.Repaint();
                                }
                            }
                            else
                            {
                                s_DragUpdatedOverID = 0;
                            }
                            if (position.Contains(current.mousePosition))
                            {
                                DragAndDrop.visualMode = InternalEditorUtility.InspectorWindowDrag(targetObjs, false);
                                Event.current.Use();
                            }
                            goto Label_02E7;

                        case EventType.DragPerform:
                            if (position.Contains(current.mousePosition))
                            {
                                DragAndDrop.visualMode = InternalEditorUtility.InspectorWindowDrag(targetObjs, true);
                                DragAndDrop.AcceptDrag();
                                Event.current.Use();
                            }
                            goto Label_02E7;

                        case EventType.ContextClick:
                            if (position.Contains(current.mousePosition) && (targetObjs[0] != null))
                            {
                                EditorUtility.DisplayObjectContextMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), targetObjs, 0);
                                current.Use();
                            }
                            goto Label_02E7;

                        default:
                            goto Label_02E7;
                    }
                    break;
            }
            current.Use();
        Label_02E7:
            GUI.enabled = enabled;
            return foldout;
        }

        public static string DoPasswordField(int id, Rect position, string password, GUIStyle style)
        {
            bool flag;
            return DoTextField(s_RecycledEditor, id, position, password, style, null, out flag, false, false, true);
        }

        public static string DoPasswordField(int id, Rect position, GUIContent label, string password, GUIStyle style)
        {
            bool flag;
            return DoTextField(s_RecycledEditor, id, PrefixLabel(position, id, label), password, style, null, out flag, false, false, true);
        }

        private static int DoPopup(Rect position, int controlID, int selected, GUIContent[] popupValues, GUIStyle style)
        {
            selected = PopupCallbackInfo.GetSelectedValueForControl(controlID, selected);
            GUIContent none = null;
            if (none == null)
            {
                if (showMixedValue)
                {
                    none = s_MixedValueContent;
                }
                else if ((selected < 0) || (selected >= popupValues.Length))
                {
                    none = GUIContent.none;
                }
                else
                {
                    none = popupValues[selected];
                }
            }
            if (Event.current.type == EventType.Repaint)
            {
                Font font = style.font;
                if (((font != null) && EditorGUIUtility.GetBoldDefaultFont()) && (font == EditorStyles.miniFont))
                {
                    style.font = EditorStyles.miniBoldFont;
                }
                BeginHandleMixedValueContentColor();
                style.Draw(position, none, controlID, false);
                EndHandleMixedValueContentColor();
                style.font = font;
                return selected;
            }
            if (((Event.current.type == EventType.MouseDown) && (Event.current.button == 0)) && position.Contains(Event.current.mousePosition))
            {
                if (Application.platform == RuntimePlatform.OSXEditor)
                {
                    position.y = (position.y - (selected * 0x10)) - 19f;
                }
                PopupCallbackInfo.instance = new PopupCallbackInfo(controlID);
                EditorUtility.DisplayCustomMenu(position, popupValues, !showMixedValue ? selected : -1, new EditorUtility.SelectMenuItemFunction(PopupCallbackInfo.instance.SetEnumValueDelegate), null);
                Event.current.Use();
            }
            return selected;
        }

        private static void DoRevertMenu(SerializedProperty property)
        {
            GenericMenu menu = new GenericMenu();
            SerializedProperty property2 = property.serializedObject.FindProperty(property.propertyPath);
            if (property.hasMultipleDifferentValues && !property.hasVisibleChildren)
            {
                TargetChoiceHandler.AddSetToValueOfTargetMenuItems(menu, property2, new TargetChoiceHandler.TargetChoiceMenuFunction(TargetChoiceHandler.SetToValueOfTarget));
            }
            if ((property.serializedObject.targetObjects.Length == 1) && property.isInstantiatedPrefab)
            {
                menu.AddItem(EditorGUIUtility.TextContent("Revert Value to Prefab"), false, new GenericMenu.MenuFunction2(TargetChoiceHandler.SetPrefabOverride), property2);
            }
            if (menu.GetItemCount() != 0)
            {
                menu.ShowAsContext();
                Event.current.Use();
            }
        }

        private static float DoSlider(Rect position, Rect dragZonePosition, int id, float value, float left, float right, string formatString)
        {
            float width = position.width;
            float kNumberW = EditorGUI.kNumberW;
            if (width >= (65f + kNumberW))
            {
                float num3 = (width - 5f) - kNumberW;
                BeginChangeCheck();
                value = GUI.HorizontalSlider(new Rect(position.x, position.y, num3, position.height), value, left, right, GUI.skin.horizontalSlider, !showMixedValue ? GUI.skin.horizontalSliderThumb : "SliderMixed");
                if (EndChangeCheck())
                {
                    float minDifference = (right - left) / ((num3 - GUI.skin.horizontalSlider.padding.horizontal) - GUI.skin.horizontalSliderThumb.fixedWidth);
                    value = MathUtils.RoundBasedOnMinimumDifference(value, minDifference);
                    if (s_RecycledEditor.IsEditingControl(id))
                    {
                        s_RecycledEditor.EndEditing();
                    }
                }
                value = DoFloatField(s_RecycledEditor, new Rect((position.x + num3) + 5f, position.y, kNumberW, position.height), dragZonePosition, id, value, formatString, EditorStyles.numberField, true);
            }
            else
            {
                width = Mathf.Min(kNumberW, width);
                position.x = position.xMax - width;
                position.width = width;
                value = DoFloatField(s_RecycledEditor, position, dragZonePosition, id, value, formatString, EditorStyles.numberField, true);
            }
            value = Mathf.Clamp(value, Mathf.Min(left, right), Mathf.Max(left, right));
            return value;
        }

        internal static string DoTextField(RecycledTextEditor editor, int id, Rect position, string text, GUIStyle style, string allowedletters, out bool changed, bool reset, bool multiline, bool passwordField)
        {
            Event current = Event.current;
            string str = text;
            if (text == null)
            {
                text = string.Empty;
            }
            if (showMixedValue)
            {
                text = string.Empty;
            }
            if (((GUIUtility.keyboardControl == id) && GUIView.current.hasFocus) && (Event.current.type != EventType.Layout))
            {
                if (editor.IsEditingControl(id))
                {
                    editor.position = position;
                    editor.style = style;
                    editor.controlID = id;
                    editor.multiline = multiline;
                    editor.isPasswordField = passwordField;
                    editor.ClampPos();
                }
                else if (!EditorGUIUtility.lookLikeInspector || RecycledTextEditor.s_ActuallyEditing)
                {
                    editor.BeginEditing(id, text, position, style, multiline, passwordField);
                    if (GUI.skin.settings.cursorColor.a > 0f)
                    {
                        editor.SelectAll();
                    }
                }
            }
            if ((editor.controlID == id) && (GUIUtility.keyboardControl != id))
            {
                editor.controlID = 0;
            }
            bool flag = false;
            string str2 = editor.content.text;
            EventType typeForControl = current.GetTypeForControl(id);
            switch (typeForControl)
            {
                case EventType.MouseDown:
                    if (position.Contains(current.mousePosition) && (current.button == 0))
                    {
                        if (!editor.IsEditingControl(id))
                        {
                            GUIUtility.keyboardControl = id;
                            editor.BeginEditing(id, text, position, style, multiline, passwordField);
                            editor.MoveCursorToPosition(Event.current.mousePosition);
                            if (GUI.skin.settings.cursorColor.a > 0f)
                            {
                                s_SelectAllOnMouseUp = true;
                            }
                        }
                        else if ((Event.current.clickCount != 2) || !GUI.skin.settings.doubleClickSelectsWord)
                        {
                            if ((Event.current.clickCount == 3) && GUI.skin.settings.tripleClickSelectsLine)
                            {
                                editor.MoveCursorToPosition(Event.current.mousePosition);
                                editor.SelectCurrentParagraph();
                                editor.MouseDragSelectsWholeWords(true);
                                editor.DblClickSnap(TextEditor.DblClickSnapping.PARAGRAPHS);
                                s_DragToPosition = false;
                            }
                            else
                            {
                                editor.MoveCursorToPosition(Event.current.mousePosition);
                                s_SelectAllOnMouseUp = false;
                            }
                        }
                        else
                        {
                            editor.MoveCursorToPosition(Event.current.mousePosition);
                            editor.SelectCurrentWord();
                            editor.MouseDragSelectsWholeWords(true);
                            editor.DblClickSnap(TextEditor.DblClickSnapping.WORDS);
                            s_DragToPosition = false;
                        }
                        GUIUtility.hotControl = id;
                        current.Use();
                    }
                    goto Label_0990;

                case EventType.MouseUp:
                    if (GUIUtility.hotControl != id)
                    {
                        goto Label_0990;
                    }
                    if (!s_Dragged || !s_DragToPosition)
                    {
                        if (s_PostPoneMove)
                        {
                            editor.MoveCursorToPosition(Event.current.mousePosition);
                        }
                        else if (s_SelectAllOnMouseUp)
                        {
                            if (GUI.skin.settings.cursorColor.a > 0f)
                            {
                                editor.SelectAll();
                            }
                            s_SelectAllOnMouseUp = false;
                        }
                    }
                    else
                    {
                        editor.MoveSelectionToAltCursor();
                        flag = true;
                    }
                    break;

                case EventType.MouseDrag:
                    if (GUIUtility.hotControl == id)
                    {
                        if ((current.shift || !editor.hasSelection) || !s_DragToPosition)
                        {
                            if (current.shift)
                            {
                                editor.MoveCursorToPosition(Event.current.mousePosition);
                            }
                            else
                            {
                                editor.SelectToPosition(Event.current.mousePosition);
                            }
                            s_DragToPosition = false;
                            s_SelectAllOnMouseUp = false;
                        }
                        else
                        {
                            editor.MoveAltCursorToPosition(Event.current.mousePosition);
                        }
                        s_Dragged = true;
                        current.Use();
                    }
                    goto Label_0990;

                case EventType.KeyDown:
                    if (GUIUtility.keyboardControl == id)
                    {
                        char character = current.character;
                        if (!editor.IsEditingControl(id) || !editor.HandleKeyEvent(current))
                        {
                            if (current.keyCode == KeyCode.Escape)
                            {
                                if (editor.IsEditingControl(id))
                                {
                                    if ((style == EditorStyles.toolbarSearchField) || (style == EditorStyles.searchField))
                                    {
                                        s_OriginalText = string.Empty;
                                    }
                                    editor.content.text = s_OriginalText;
                                    editor.EndEditing();
                                    flag = true;
                                    if (!EditorGUIUtility.lookLikeInspector)
                                    {
                                        GUIUtility.keyboardControl = 0;
                                    }
                                }
                            }
                            else
                            {
                                switch (character)
                                {
                                    case '\n':
                                    case '\x0003':
                                        if ((editor.IsEditingControl(id) && !multiline) && !current.alt)
                                        {
                                            editor.EndEditing();
                                            if (!EditorGUIUtility.lookLikeInspector)
                                            {
                                                GUIUtility.keyboardControl = 0;
                                            }
                                        }
                                        else if (EditorGUIUtility.lookLikeInspector && !editor.IsEditingControl(id))
                                        {
                                            editor.BeginEditing(id, text, position, style, multiline, passwordField);
                                            editor.SelectAll();
                                        }
                                        else
                                        {
                                            editor.Insert(character);
                                            flag = true;
                                            goto Label_0990;
                                        }
                                        current.Use();
                                        goto Label_0990;
                                }
                                if (((((character != '\t') && (current.keyCode != KeyCode.Tab)) && (character != '\x0019')) && (character != '\x001b')) && editor.IsEditingControl(id))
                                {
                                    if (((allowedletters == null) || (allowedletters.IndexOf(character) != -1)) && (character != '\0'))
                                    {
                                        editor.Insert(character);
                                        flag = true;
                                    }
                                    else
                                    {
                                        if (Input.compositionString != string.Empty)
                                        {
                                            editor.ReplaceSelection(string.Empty);
                                            flag = true;
                                        }
                                        current.Use();
                                    }
                                }
                            }
                        }
                        else
                        {
                            current.Use();
                            flag = true;
                        }
                    }
                    goto Label_0990;

                case EventType.Repaint:
                    string str3;
                    if (!editor.IsEditingControl(id))
                    {
                        if (showMixedValue)
                        {
                            str3 = s_MixedValueContent.text;
                        }
                        else
                        {
                            str3 = !passwordField ? text : string.Empty.PadRight(text.Length, '*');
                        }
                    }
                    else
                    {
                        str3 = !passwordField ? editor.content.text : string.Empty.PadRight(editor.content.text.Length, '*');
                    }
                    if (GUIUtility.hotControl == 0)
                    {
                        EditorGUIUtility.AddCursorRect(position, MouseCursor.Text);
                    }
                    if (EditorGUIUtility.lookLikeInspector)
                    {
                        if (!editor.IsEditingControl(id))
                        {
                            BeginHandleMixedValueContentColor();
                            style.Draw(position, EditorGUIUtility.TempContent(str3), id, false);
                            EndHandleMixedValueContentColor();
                        }
                        else
                        {
                            Texture2D background = style.focused.background;
                            Color textColor = style.focused.textColor;
                            style.focused.background = style.onNormal.background;
                            style.focused.textColor = style.onNormal.textColor;
                            editor.DrawCursor(str3);
                            style.focused.background = background;
                            style.focused.textColor = textColor;
                        }
                    }
                    else if (!editor.IsEditingControl(id))
                    {
                        BeginHandleMixedValueContentColor();
                        style.Draw(position, EditorGUIUtility.TempContent(str3), id, false);
                        EndHandleMixedValueContentColor();
                    }
                    else
                    {
                        editor.DrawCursor(str3);
                    }
                    goto Label_0990;

                default:
                    string commandName;
                    Dictionary<string, int> dictionary;
                    int num;
                    switch (typeForControl)
                    {
                        case EventType.ValidateCommand:
                            if (GUIUtility.keyboardControl == id)
                            {
                                commandName = current.commandName;
                                if (commandName != null)
                                {
                                    if (<>f__switch$mapD == null)
                                    {
                                        dictionary = new Dictionary<string, int>(5);
                                        dictionary.Add("Cut", 0);
                                        dictionary.Add("Copy", 0);
                                        dictionary.Add("Paste", 1);
                                        dictionary.Add("SelectAll", 2);
                                        dictionary.Add("UndoRedoPerformed", 3);
                                        <>f__switch$mapD = dictionary;
                                    }
                                    if (<>f__switch$mapD.TryGetValue(commandName, out num))
                                    {
                                        switch (num)
                                        {
                                            case 0:
                                                if (editor.hasSelection)
                                                {
                                                    current.Use();
                                                }
                                                break;

                                            case 1:
                                                if (editor.CanPaste())
                                                {
                                                    current.Use();
                                                }
                                                break;

                                            case 2:
                                                current.Use();
                                                break;

                                            case 3:
                                                editor.content.text = text;
                                                current.Use();
                                                break;
                                        }
                                    }
                                }
                            }
                            goto Label_0990;

                        case EventType.ExecuteCommand:
                            if (GUIUtility.keyboardControl == id)
                            {
                                commandName = current.commandName;
                                if (commandName != null)
                                {
                                    if (<>f__switch$mapE == null)
                                    {
                                        dictionary = new Dictionary<string, int>(5);
                                        dictionary.Add("OnLostFocus", 0);
                                        dictionary.Add("Cut", 1);
                                        dictionary.Add("Copy", 2);
                                        dictionary.Add("Paste", 3);
                                        dictionary.Add("SelectAll", 4);
                                        <>f__switch$mapE = dictionary;
                                    }
                                    if (<>f__switch$mapE.TryGetValue(commandName, out num))
                                    {
                                        switch (num)
                                        {
                                            case 0:
                                                if (activeEditor != null)
                                                {
                                                    activeEditor.EndEditing();
                                                }
                                                current.Use();
                                                break;

                                            case 1:
                                                editor.BeginEditing(id, text, position, style, multiline, passwordField);
                                                editor.Cut();
                                                flag = true;
                                                break;

                                            case 2:
                                                editor.Copy();
                                                current.Use();
                                                break;

                                            case 3:
                                                editor.BeginEditing(id, text, position, style, multiline, passwordField);
                                                editor.Paste();
                                                flag = true;
                                                break;

                                            case 4:
                                                editor.SelectAll();
                                                current.Use();
                                                break;
                                        }
                                    }
                                }
                            }
                            goto Label_0990;

                        case EventType.DragExited:
                            goto Label_0990;

                        case EventType.ContextClick:
                            if (position.Contains(current.mousePosition))
                            {
                                if (!editor.IsEditingControl(id))
                                {
                                    GUIUtility.keyboardControl = id;
                                    editor.BeginEditing(id, text, position, style, multiline, passwordField);
                                    editor.MoveCursorToPosition(Event.current.mousePosition);
                                }
                                ShowTextEditorPopupMenu();
                                Event.current.Use();
                            }
                            goto Label_0990;

                        default:
                            goto Label_0990;
                    }
                    break;
            }
            editor.MouseDragSelectsWholeWords(false);
            s_DragToPosition = true;
            s_Dragged = false;
            s_PostPoneMove = false;
            if (current.button == 0)
            {
                GUIUtility.hotControl = 0;
                current.Use();
            }
        Label_0990:
            if (GUIUtility.keyboardControl == id)
            {
                GUIUtility.textFieldInput = true;
            }
            changed = false;
            if (flag)
            {
                changed = str2 != editor.content.text;
                current.Use();
            }
            if (changed)
            {
                GUI.changed = true;
                return editor.content.text;
            }
            RecycledTextEditor.s_AllowContextCutOrPaste = true;
            return str;
        }

        internal static bool DoToggle(Rect position, int id, bool value, GUIContent content, GUIStyle style)
        {
            return EditorGUIInternal.DoToggleForward(position, id, value, content, style);
        }

        private static void DragNumberValue(RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, bool isFloat, ref float floatVal, ref int intVal, string formatString, GUIStyle style, float dragSensitivity)
        {
            Event current = Event.current;
            switch (current.GetTypeForControl(id))
            {
                case EventType.MouseDown:
                    if (dragHotZone.Contains(current.mousePosition) && (current.button == 0))
                    {
                        GUIUtility.hotControl = id;
                        if (EditorGUIUtility.lookLikeInspector)
                        {
                            if (activeEditor != null)
                            {
                                activeEditor.EndEditing();
                            }
                            current.Use();
                            GUIUtility.keyboardControl = id;
                        }
                        s_DragCandidateState = 1;
                        s_DragStartValue = floatVal;
                        s_DragStartIntValue = intVal;
                        s_DragStartPos = current.mousePosition;
                        s_DragSensitivity = dragSensitivity;
                        current.Use();
                        EditorGUIUtility.SetWantsMouseJumping(1);
                    }
                    return;

                case EventType.MouseUp:
                    if ((GUIUtility.hotControl != id) || (s_DragCandidateState == 0))
                    {
                        return;
                    }
                    if (!EditorGUIUtility.lookLikeInspector)
                    {
                        if (s_DragCandidateState == 2)
                        {
                            if (editor != null)
                            {
                                editor.EndEditing();
                            }
                            GUIUtility.keyboardControl = 0;
                        }
                        break;
                    }
                    break;

                case EventType.MouseMove:
                case EventType.KeyUp:
                case EventType.ScrollWheel:
                    return;

                case EventType.MouseDrag:
                    if (GUIUtility.hotControl == id)
                    {
                        switch (s_DragCandidateState)
                        {
                            case 1:
                            {
                                Vector2 vector = Event.current.mousePosition - s_DragStartPos;
                                if (vector.sqrMagnitude > kDragDeadzone)
                                {
                                    s_DragCandidateState = 2;
                                    if (!EditorGUIUtility.lookLikeInspector)
                                    {
                                        editor.BeginEditing(id, !isFloat ? ((int) intVal).ToString(formatString) : ((float) floatVal).ToString(formatString), position, style, false, false);
                                    }
                                    GUIUtility.keyboardControl = id;
                                }
                                current.Use();
                                break;
                            }
                            case 2:
                                if (isFloat)
                                {
                                    floatVal += HandleUtility.niceMouseDelta * s_DragSensitivity;
                                    floatVal = MathUtils.RoundBasedOnMinimumDifference(floatVal, s_DragSensitivity);
                                }
                                else
                                {
                                    intVal += Mathf.RoundToInt(HandleUtility.niceMouseDelta * s_DragSensitivity);
                                }
                                GUI.changed = true;
                                current.Use();
                                break;
                        }
                    }
                    return;

                case EventType.KeyDown:
                    if (((GUIUtility.hotControl == id) && (current.keyCode == KeyCode.Escape)) && (s_DragCandidateState != 0))
                    {
                        floatVal = s_DragStartValue;
                        intVal = s_DragStartIntValue;
                        GUI.changed = true;
                        GUIUtility.hotControl = 0;
                        if (!EditorGUIUtility.lookLikeInspector)
                        {
                            GUIUtility.keyboardControl = 0;
                        }
                        current.Use();
                    }
                    return;

                case EventType.Repaint:
                    if ((((editor != null) && (s_DragCandidateState == 2)) && !EditorGUIUtility.lookLikeInspector) && (editor.content.text != (!isFloat ? ((int) intVal).ToString(formatString) : ((float) floatVal).ToString(formatString))))
                    {
                        editor.content.text = !isFloat ? ((int) intVal).ToString(formatString) : ((float) floatVal).ToString(formatString);
                        editor.SelectAll();
                    }
                    EditorGUIUtility.AddCursorRect(dragHotZone, MouseCursor.SlideArrow);
                    return;

                default:
                    return;
            }
            GUIUtility.hotControl = 0;
            s_DragCandidateState = 0;
            current.Use();
            EditorGUIUtility.SetWantsMouseJumping(0);
        }

        private static void Draw4(Rect position, GUIContent content, float offset, float alpha, GUIStyle style)
        {
            GUI.color = new Color(0f, 0f, 0f, alpha);
            position.y -= offset;
            style.Draw(position, content, false, false, false, false);
            position.y += offset * 2f;
            style.Draw(position, content, false, false, false, false);
            position.y -= offset;
            position.x -= offset;
            style.Draw(position, content, false, false, false, false);
            position.x += offset * 2f;
            style.Draw(position, content, false, false, false, false);
        }

        internal static void DrawBezier(Vector2 from, Vector2 to, Vector2 fromTangent, Vector2 toTangent, int thickness, Color color)
        {
            if (Event.current.type == EventType.Repaint)
            {
                if (s_Texture == null)
                {
                    s_Texture = new Texture2D(1, thickness + 2);
                    s_Texture.hideFlags = HideFlags.HideAndDontSave;
                }
                if (thickness != s_LastThickness)
                {
                    s_Texture.Resize(1, thickness + 2, TextureFormat.ARGB32, false);
                    Color[] colors = new Color[thickness + 2];
                    for (int i = 1; i <= thickness; i++)
                    {
                        colors[i] = new Color(1f, 1f, 1f, 1f);
                    }
                    colors[0] = colors[thickness + 1] = new Color(1f, 1f, 1f, 0f);
                    s_Texture.SetPixels(colors);
                    s_Texture.Apply();
                    s_LastThickness = thickness;
                }
                DrawBezier(from, to, fromTangent, toTangent, thickness, color, s_Texture);
            }
        }

        internal static void DrawBezier(Vector2 from, Vector2 to, Vector2 fromTangent, Vector2 toTangent, int thickness, Color color, Texture tex)
        {
            if (Event.current.type == EventType.Repaint)
            {
                if (tmp == null)
                {
                    tmp = new Material("Shader \"GuiShader\" {\n\tProperties {\t\t_Color (\",\", Color) = (1,1,1,1)\n\t\t_Tex (\",\", Any) = \"white\" {}\n\t}\tSubShader { Pass {\n\t\tTags { \"ForceSupported\" = \"True\" } \n \t\tZTest Always Cull Off ZWrite Off Lighting Off Color [_Color] \t\tBlend SrcAlpha OneMinusSrcAlpha \t\tSetTexture [_Tex] { combine texture * previous }\t}}\n}");
                    tmp.hideFlags = HideFlags.HideAndDontSave;
                    tmp.shader.hideFlags = HideFlags.HideAndDontSave;
                }
                tmp.SetTexture("_Tex", tex);
                tmp.SetColor("_Color", color);
                tmp.SetPass(0);
            }
        }

        private static Rect DrawBoundsFieldLabelsAndAdjustPositionForValues(Rect position)
        {
            GUI.Label(IndentedRect(position), "Center:", EditorStyles.label);
            position.y += 16f;
            GUI.Label(IndentedRect(position), "Extents:", EditorStyles.label);
            position.y -= 16f;
            position.x += 50f;
            position.width -= 50f;
            return position;
        }

        internal static void DrawLabelShadow(Rect position, GUIContent content, GUIStyle style, float shadowOpa)
        {
            Color color = GUI.color;
            Color contentColor = GUI.contentColor;
            Color backgroundColor = GUI.backgroundColor;
            GUI.contentColor = new Color(0f, 0f, 0f, 0f);
            style.Draw(position, content, false, false, false, false);
            position.y++;
            GUI.backgroundColor = new Color(0f, 0f, 0f, 0f);
            GUI.contentColor = contentColor;
            Draw4(position, content, 1f, GUI.color.a * shadowOpa, style);
            Draw4(position, content, 2f, (GUI.color.a * shadowOpa) * 0.42f, style);
            GUI.color = color;
            GUI.backgroundColor = backgroundColor;
        }

        internal static void DrawLegend(Rect position, Color color, string label, bool enabled)
        {
            position = new Rect(position.x + 2f, position.y + 2f, position.width - 2f, position.height - 2f);
            Color backgroundColor = GUI.backgroundColor;
            if (enabled)
            {
                GUI.backgroundColor = color;
            }
            else
            {
                GUI.backgroundColor = new Color(0.5f, 0.5f, 0.5f, 0.45f);
            }
            GUI.Label(position, label, "ProfilerPaneSubLabel");
            GUI.backgroundColor = backgroundColor;
        }

        public static void DrawPreviewTexture(Rect position, Texture image)
        {
            float imageAspect = 0f;
            ScaleMode stretchToFill = ScaleMode.StretchToFill;
            Material mat = null;
            DrawPreviewTexture(position, image, mat, stretchToFill, imageAspect);
        }

        public static void DrawPreviewTexture(Rect position, Texture image, Material mat)
        {
            float imageAspect = 0f;
            ScaleMode stretchToFill = ScaleMode.StretchToFill;
            DrawPreviewTexture(position, image, mat, stretchToFill, imageAspect);
        }

        public static void DrawPreviewTexture(Rect position, Texture image, Material mat, ScaleMode scaleMode)
        {
            float imageAspect = 0f;
            DrawPreviewTexture(position, image, mat, scaleMode, imageAspect);
        }

        public static void DrawPreviewTexture(Rect position, Texture image, Material mat, ScaleMode scaleMode, float imageAspect)
        {
            if (Event.current.type == EventType.Repaint)
            {
                if (mat == null)
                {
                    mat = GetMaterialForSpecialTexture(image);
                }
                if (mat == null)
                {
                    GUI.DrawTexture(position, image, scaleMode, false, imageAspect);
                }
                else
                {
                    if (imageAspect == 0f)
                    {
                        imageAspect = ((float) image.width) / ((float) image.height);
                    }
                    float num = position.width / position.height;
                    switch (scaleMode)
                    {
                        case ScaleMode.StretchToFill:
                            Graphics.DrawTexture(position, image, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, GUI.color, mat);
                            break;

                        case ScaleMode.ScaleAndCrop:
                        {
                            if (num <= imageAspect)
                            {
                                float width = num / imageAspect;
                                Graphics.DrawTexture(position, image, new Rect(0.5f - (width * 0.5f), 0f, width, 1f), 0, 0, 0, 0, GUI.color, mat);
                                break;
                            }
                            float height = imageAspect / num;
                            Graphics.DrawTexture(position, image, new Rect(0f, (1f - height) * 0.5f, 1f, height), 0, 0, 0, 0, GUI.color, mat);
                            break;
                        }
                        case ScaleMode.ScaleToFit:
                        {
                            if (num <= imageAspect)
                            {
                                float num5 = num / imageAspect;
                                Graphics.DrawTexture(new Rect(position.xMin, position.yMin + ((position.height * (1f - num5)) * 0.5f), position.width, num5 * position.height), image, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, GUI.color, mat);
                                break;
                            }
                            float num4 = imageAspect / num;
                            Graphics.DrawTexture(new Rect(position.xMin + ((position.width * (1f - num4)) * 0.5f), position.yMin, num4 * position.width, position.height), image, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, GUI.color, mat);
                            break;
                        }
                    }
                }
            }
        }

        public static void DrawTextureAlpha(Rect position, Texture image)
        {
            float imageAspect = 0f;
            ScaleMode stretchToFill = ScaleMode.StretchToFill;
            DrawTextureAlpha(position, image, stretchToFill, imageAspect);
        }

        public static void DrawTextureAlpha(Rect position, Texture image, ScaleMode scaleMode)
        {
            float imageAspect = 0f;
            DrawTextureAlpha(position, image, scaleMode, imageAspect);
        }

        public static void DrawTextureAlpha(Rect position, Texture image, ScaleMode scaleMode, float imageAspect)
        {
            DrawPreviewTexture(position, image, alphaMaterial, scaleMode, imageAspect);
        }

        public static void DropShadowLabel(Rect position, string text)
        {
            DoDropShadowLabel(position, EditorGUIUtility.TempContent(text), "PreOverlayLabel", 0.6f);
        }

        public static void DropShadowLabel(Rect position, GUIContent content)
        {
            DoDropShadowLabel(position, content, "PreOverlayLabel", 0.6f);
        }

        public static void DropShadowLabel(Rect position, string text, GUIStyle style)
        {
            DoDropShadowLabel(position, EditorGUIUtility.TempContent(text), style, 0.6f);
        }

        public static void DropShadowLabel(Rect position, GUIContent content, GUIStyle style)
        {
            DoDropShadowLabel(position, content, style, 0.6f);
        }

        public static bool EndChangeCheck()
        {
            bool changed = GUI.changed;
            GUI.changed |= s_ChangedStack.Pop();
            return changed;
        }

        internal static void EndCollectTooltips()
        {
            isCollectingTooltips = false;
        }

        public static void EndDisabledGroup()
        {
            GUI.enabled = s_EnabledStack.Pop();
        }

        internal static void EndEditingActiveTextField()
        {
            if (activeEditor != null)
            {
                activeEditor.EndEditing();
            }
        }

        internal static void EndHandleMixedValueContentColor()
        {
            GUI.contentColor = s_MixedValueContentColorTemp;
        }

        public static void EndProperty()
        {
            showMixedValue = false;
            PropertyGUIData data = s_PropertyStack.Pop();
            if ((Event.current.type == EventType.ContextClick) && data.totalPosition.Contains(Event.current.mousePosition))
            {
                DoRevertMenu(data.property);
            }
            EditorGUIUtility.SetBoldDefaultFont(data.wasBoldDefaultFont);
            GUI.enabled = data.wasEnabled;
        }

        public static Enum EnumMaskField(Rect position, Enum enumValue)
        {
            GUIStyle popup = EditorStyles.popup;
            return EnumMaskField(position, enumValue, popup);
        }

        public static Enum EnumMaskField(Rect position, Enum enumValue, GUIStyle style)
        {
            if (!enumValue.GetType().IsEnum)
            {
                throw new System.Exception("parameter _enum must be of type System.Enum");
            }
            if (<>f__am$cache5A == null)
            {
                <>f__am$cache5A = x => ObjectNames.NicifyVariableName(x);
            }
            string[] flagNames = Enumerable.Select<string, string>(Enum.GetNames(enumValue.GetType()), <>f__am$cache5A).ToArray<string>();
            int num = MaskFieldGUI.DoMaskField(IndentedRect(position), GetControlID(s_MaskField, EditorGUIUtility.native, position), Convert.ToInt32(enumValue), flagNames, style);
            return (Enum.Parse(enumValue.GetType(), num.ToString()) as Enum);
        }

        public static Enum EnumMaskField(Rect position, string label, Enum enumValue)
        {
            GUIStyle popup = EditorStyles.popup;
            return EnumMaskField(position, label, enumValue, popup);
        }

        public static Enum EnumMaskField(Rect position, GUIContent label, Enum enumValue)
        {
            GUIStyle popup = EditorStyles.popup;
            return EnumMaskField(position, label, enumValue, popup);
        }

        public static Enum EnumMaskField(Rect position, string label, Enum enumValue, GUIStyle style)
        {
            return EnumMaskField(position, EditorGUIUtility.TempContent(label), enumValue, style);
        }

        public static Enum EnumMaskField(Rect position, GUIContent label, Enum enumValue, GUIStyle style)
        {
            if (!enumValue.GetType().IsEnum)
            {
                throw new System.Exception("parameter _enum must be of type System.Enum");
            }
            int id = GetControlID(s_MaskField, EditorGUIUtility.native, position);
            Rect rect = PrefixLabel(position, id, label);
            position.xMax = rect.x;
            if (<>f__am$cache59 == null)
            {
                <>f__am$cache59 = x => ObjectNames.NicifyVariableName(x);
            }
            string[] flagNames = Enumerable.Select<string, string>(Enum.GetNames(enumValue.GetType()), <>f__am$cache59).ToArray<string>();
            return (Enum.Parse(enumValue.GetType(), MaskFieldGUI.DoMaskField(rect, id, Convert.ToInt32(enumValue), flagNames, style).ToString()) as Enum);
        }

        internal static Enum EnumMaskField(Rect position, Enum enumValue, GUIStyle style, out int changedFlags, out bool changedToValue)
        {
            if (!enumValue.GetType().IsEnum)
            {
                throw new System.Exception("parameter _enum must be of type System.Enum");
            }
            if (<>f__am$cache5B == null)
            {
                <>f__am$cache5B = x => ObjectNames.NicifyVariableName(x);
            }
            string[] flagNames = Enumerable.Select<string, string>(Enum.GetNames(enumValue.GetType()), <>f__am$cache5B).ToArray<string>();
            int num = MaskFieldGUI.DoMaskField(IndentedRect(position), GetControlID(s_MaskField, EditorGUIUtility.native, position), Convert.ToInt32(enumValue), flagNames, style, out changedFlags, out changedToValue);
            return (Enum.Parse(enumValue.GetType(), num.ToString()) as Enum);
        }

        public static Enum EnumPopup(Rect position, Enum selected)
        {
            GUIStyle popup = EditorStyles.popup;
            return EnumPopup(position, selected, popup);
        }

        public static Enum EnumPopup(Rect position, Enum selected, GUIStyle style)
        {
            return EnumPopup(position, GUIContent.none, selected, style);
        }

        public static Enum EnumPopup(Rect position, string label, Enum selected)
        {
            GUIStyle popup = EditorStyles.popup;
            return EnumPopup(position, label, selected, popup);
        }

        public static Enum EnumPopup(Rect position, GUIContent label, Enum selected)
        {
            GUIStyle popup = EditorStyles.popup;
            return EnumPopup(position, label, selected, popup);
        }

        public static Enum EnumPopup(Rect position, string label, Enum selected, GUIStyle style)
        {
            return EnumPopup(position, EditorGUIUtility.TempContent(label), selected, style);
        }

        public static Enum EnumPopup(Rect position, GUIContent label, Enum selected, GUIStyle style)
        {
            System.Type enumType = selected.GetType();
            if (!enumType.IsEnum)
            {
                throw new System.Exception("parameter _enum must be of type System.Enum");
            }
            string[] names = Enum.GetNames(enumType);
            int index = Array.IndexOf<string>(names, Enum.GetName(enumType, selected));
            if (<>f__am$cache58 == null)
            {
                <>f__am$cache58 = x => ObjectNames.NicifyVariableName(x);
            }
            index = Popup(position, label, index, EditorGUIUtility.TempContent(Enumerable.Select<string, string>(names, <>f__am$cache58).ToArray<string>()), style);
            if ((index >= 0) && (index < names.Length))
            {
                return (Enum) Enum.Parse(enumType, names[index]);
            }
            return selected;
        }

        public static float FloatField(Rect position, float value)
        {
            GUIStyle numberField = EditorStyles.numberField;
            return FloatField(position, value, numberField);
        }

        public static float FloatField(Rect position, float value, GUIStyle style)
        {
            int id = GetControlID(s_FloatFieldHash, FocusType.Keyboard, position);
            return DoFloatField(s_RecycledEditor, IndentedRect(position), new Rect(0f, 0f, 0f, 0f), id, value, kFloatFieldFormatString, style, false);
        }

        public static float FloatField(Rect position, string label, float value)
        {
            GUIStyle numberField = EditorStyles.numberField;
            return FloatField(position, label, value, numberField);
        }

        public static float FloatField(Rect position, GUIContent label, float value)
        {
            GUIStyle numberField = EditorStyles.numberField;
            return FloatField(position, label, value, numberField);
        }

        public static float FloatField(Rect position, string label, float value, GUIStyle style)
        {
            return FloatField(position, EditorGUIUtility.TempContent(label), value, style);
        }

        public static float FloatField(Rect position, GUIContent label, float value, GUIStyle style)
        {
            int id = GetControlID(s_FloatFieldHash, FocusType.Keyboard, position);
            Rect rect = PrefixLabel(position, id, label);
            position.xMax = rect.x;
            return DoFloatField(s_RecycledEditor, rect, position, id, value, kFloatFieldFormatString, style, true);
        }

        public static bool Foldout(Rect position, bool foldout, string content)
        {
            GUIStyle style = EditorStyles.foldout;
            return Foldout(position, foldout, content, style);
        }

        public static bool Foldout(Rect position, bool foldout, GUIContent content)
        {
            GUIStyle style = EditorStyles.foldout;
            return Foldout(position, foldout, content, style);
        }

        public static bool Foldout(Rect position, bool foldout, string content, bool toggleOnLabelClick)
        {
            GUIStyle style = EditorStyles.foldout;
            return Foldout(position, foldout, content, toggleOnLabelClick, style);
        }

        public static bool Foldout(Rect position, bool foldout, string content, GUIStyle style)
        {
            return Foldout(position, foldout, EditorGUIUtility.TempContent(content), false, style);
        }

        public static bool Foldout(Rect position, bool foldout, GUIContent content, bool toggleOnLabelClick)
        {
            GUIStyle style = EditorStyles.foldout;
            return Foldout(position, foldout, content, toggleOnLabelClick, style);
        }

        public static bool Foldout(Rect position, bool foldout, GUIContent content, GUIStyle style)
        {
            return Foldout(position, foldout, content, false, style);
        }

        public static bool Foldout(Rect position, bool foldout, string content, bool toggleOnLabelClick, GUIStyle style)
        {
            return Foldout(position, foldout, EditorGUIUtility.TempContent(content), toggleOnLabelClick, style);
        }

        public static bool Foldout(Rect position, bool foldout, GUIContent content, bool toggleOnLabelClick, GUIStyle style)
        {
            int controlID = GetControlID(s_FoldoutHash, EditorGUIUtility.native, position);
            EventType rawType = Event.current.type;
            if ((!GUI.enabled && GUIClip.enabled) && (((Event.current.rawType == EventType.MouseDown) || (Event.current.rawType == EventType.MouseDrag)) || (Event.current.rawType == EventType.MouseUp)))
            {
                rawType = Event.current.rawType;
            }
            switch (rawType)
            {
                case EventType.MouseDown:
                    if (position.Contains(Event.current.mousePosition) && (Event.current.button == 0))
                    {
                        int num3 = controlID;
                        GUIUtility.hotControl = num3;
                        GUIUtility.keyboardControl = num3;
                        Event.current.Use();
                    }
                    return foldout;

                case EventType.MouseUp:
                {
                    if (GUIUtility.hotControl != controlID)
                    {
                        return foldout;
                    }
                    GUIUtility.hotControl = 0;
                    Event.current.Use();
                    Rect rect = position;
                    if (!toggleOnLabelClick)
                    {
                        rect.width = style.padding.left;
                        rect.x += indent;
                    }
                    if (!rect.Contains(Event.current.mousePosition))
                    {
                        return foldout;
                    }
                    GUI.changed = true;
                    return !foldout;
                }
                case EventType.MouseDrag:
                    if (GUIUtility.hotControl == controlID)
                    {
                        Event.current.Use();
                    }
                    return foldout;

                case EventType.KeyDown:
                    if (GUIUtility.keyboardControl == controlID)
                    {
                        KeyCode keyCode = Event.current.keyCode;
                        if (((keyCode != KeyCode.LeftArrow) || !foldout) && ((keyCode != KeyCode.RightArrow) || foldout))
                        {
                            return foldout;
                        }
                        foldout = !foldout;
                        GUI.changed = true;
                        Event.current.Use();
                    }
                    return foldout;

                case EventType.Repaint:
                {
                    EditorStyles.foldoutSelected.Draw(position, GUIContent.none, controlID, s_DragUpdatedOverID == controlID);
                    float labelWidth = EditorGUIUtility.labelWidth;
                    Rect rect2 = new Rect(position.x + indent, position.y, labelWidth - indent, position.height);
                    if (!showMixedValue || foldout)
                    {
                        style.Draw(rect2, content, controlID, foldout);
                        return foldout;
                    }
                    style.Draw(rect2, content, controlID, foldout);
                    BeginHandleMixedValueContentColor();
                    Rect rect3 = position;
                    if (EditorGUIUtility.lookLikeInspector)
                    {
                        rect3.xMin += EditorStyles.foldout.padding.left - EditorStyles.label.padding.left;
                    }
                    rect3.xMin += labelWidth;
                    EditorStyles.label.Draw(rect3, s_MixedValueContent, controlID, false);
                    EndHandleMixedValueContentColor();
                    return foldout;
                }
                case EventType.DragUpdated:
                    if (s_DragUpdatedOverID != controlID)
                    {
                        if (position.Contains(Event.current.mousePosition))
                        {
                            s_DragUpdatedOverID = controlID;
                            s_FoldoutDestTime = Time.realtimeSinceStartup + 0.7;
                            Event.current.Use();
                        }
                        return foldout;
                    }
                    if (!position.Contains(Event.current.mousePosition))
                    {
                        s_DragUpdatedOverID = 0;
                        return foldout;
                    }
                    if (Time.realtimeSinceStartup > s_FoldoutDestTime)
                    {
                        foldout = true;
                        Event.current.Use();
                    }
                    return foldout;

                case EventType.DragExited:
                    if (s_DragUpdatedOverID == controlID)
                    {
                        s_DragUpdatedOverID = 0;
                        Event.current.Use();
                    }
                    return foldout;
            }
            return foldout;
        }

        internal static int GetControlID(int hash, FocusType fType, Rect position)
        {
            lastControlID = GUIUtility.GetControlID(hash, fType, position);
            return lastControlID;
        }

        internal static Material GetMaterialForSpecialTexture(Texture t)
        {
            if (t != null)
            {
                switch (TextureUtil.GetUsageMode(t))
                {
                    case TextureUsageMode.LightmapRGBM:
                        return lightmapRGBMMaterial;

                    case TextureUsageMode.LightmapDoubleLDR:
                        return lightmapDoubleLDRMaterial;

                    case TextureUsageMode.NormalmapPlain:
                    case TextureUsageMode.NormalmapDXT5nm:
                        return normalmapMaterial;
                }
                if (TextureUtil.IsAlphaOnlyTextureFormat(TextureUtil.GetTextureFormat(t)))
                {
                    return alphaMaterial;
                }
                if ((QualitySettings.activeColorSpace == ColorSpace.Linear) && !TextureUtil.GetLinearSampled(t))
                {
                    return gammaCorrectMaterial;
                }
            }
            return null;
        }

        private static float GetMultiFieldLabelWidth(int fields)
        {
            return ((fields > 2) ? 18f : 35f);
        }

        public static float GetPropertyHeight(SerializedProperty property)
        {
            bool includeChildren = true;
            GUIContent label = null;
            return GetPropertyHeight(property, label, includeChildren);
        }

        public static float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            bool includeChildren = true;
            return GetPropertyHeight(property, label, includeChildren);
        }

        public static float GetPropertyHeight(SerializedProperty property, GUIContent label, bool includeChildren)
        {
            PropertyDrawer drawer = PropertyDrawer.GetDrawer(property);
            if (drawer != null)
            {
                if (label == null)
                {
                }
                return drawer.GetPropertyHeight(property.Copy(), EditorGUIUtility.TempContent(property.displayName));
            }
            if (!includeChildren)
            {
                return GetSinglePropertyHeight(property, label);
            }
            property = property.Copy();
            SerializedProperty endProperty = property.GetEndProperty();
            float singlePropertyHeight = GetSinglePropertyHeight(property, label);
            bool enterChildren = property.isExpanded && HasVisibleChildFields(property);
            while (property.NextVisible(enterChildren) && !SerializedProperty.EqualContents(property, endProperty))
            {
                drawer = PropertyDrawer.GetDrawer(property);
                if (drawer != null)
                {
                    singlePropertyHeight += drawer.GetPropertyHeight(property.Copy(), EditorGUIUtility.TempContent(property.displayName));
                    enterChildren = false;
                }
                else
                {
                    singlePropertyHeight += GetSinglePropertyHeight(property);
                    enterChildren = property.isExpanded && HasVisibleChildFields(property);
                }
            }
            return singlePropertyHeight;
        }

        internal static float GetSinglePropertyHeight(SerializedProperty property)
        {
            GUIContent label = null;
            return GetSinglePropertyHeight(property, label);
        }

        internal static float GetSinglePropertyHeight(SerializedProperty property, GUIContent label)
        {
            if (property != null)
            {
                if (EditorGUIUtility.lookLikeInspector)
                {
                    return 16f;
                }
                switch (property.propertyType)
                {
                    case SerializedPropertyType.Vector3:
                        return ((LabelHasContent(label) ? 19f : 0f) + 16f);

                    case SerializedPropertyType.Rect:
                    case SerializedPropertyType.Bounds:
                        return ((LabelHasContent(label) ? 19f : 0f) + 32f);
                }
            }
            return 16f;
        }

        internal static Gradient GradientField(Rect position, SerializedProperty gradient)
        {
            int id = GetControlID(s_GradientHash, EditorGUIUtility.native, position);
            return DoGradientField(position, id, null, gradient);
        }

        internal static Gradient GradientField(Rect position, Gradient gradient)
        {
            int id = GetControlID(s_GradientHash, EditorGUIUtility.native, position);
            return DoGradientField(position, id, gradient, null);
        }

        internal static Gradient GradientField(string label, Rect position, SerializedProperty property)
        {
            return GradientField(EditorGUIUtility.TempContent(label), position, property);
        }

        internal static Gradient GradientField(string label, Rect position, Gradient gradient)
        {
            return GradientField(EditorGUIUtility.TempContent(label), position, gradient);
        }

        internal static Gradient GradientField(GUIContent label, Rect position, SerializedProperty property)
        {
            int id = GetControlID(s_GradientHash, EditorGUIUtility.native, position);
            return DoGradientField(PrefixLabel(position, id, label), id, null, property);
        }

        internal static Gradient GradientField(GUIContent label, Rect position, Gradient gradient)
        {
            int id = GetControlID(s_GradientHash, EditorGUIUtility.native, position);
            return DoGradientField(PrefixLabel(position, id, label), id, gradient, null);
        }

        internal static bool HasVisibleChildFields(SerializedProperty property)
        {
            if (!EditorGUIUtility.lookLikeInspector)
            {
                switch (property.propertyType)
                {
                    case SerializedPropertyType.Vector3:
                    case SerializedPropertyType.Rect:
                    case SerializedPropertyType.Bounds:
                        return false;
                }
            }
            return property.hasVisibleChildren;
        }

        public static void HelpBox(Rect position, string message, MessageType type)
        {
            GUI.Label(position, EditorGUIUtility.TempContent(message, EditorGUIUtility.GetHelpIcon(type)), EditorStyles.helpBox);
        }

        internal static bool HelpIconButton(Rect position, UnityEngine.Object obj)
        {
            if (s_HelpIcon == null)
            {
                s_HelpIcon = EditorGUIUtility.IconContent("_Help");
            }
            bool flag = Unsupported.IsDeveloperBuild();
            bool defaultToMonoBehaviour = !flag || obj.GetType().Assembly.ToString().StartsWith("Assembly-");
            bool flag3 = Help.HasHelpForObject(obj, defaultToMonoBehaviour);
            if (!flag3 && !flag)
            {
                return false;
            }
            Color color = GUI.color;
            GUIContent content = new GUIContent(s_HelpIcon);
            string niceHelpNameForObject = Help.GetNiceHelpNameForObject(obj, defaultToMonoBehaviour);
            if (flag && !flag3)
            {
                GUI.color = Color.yellow;
                string str2 = (!(obj is MonoBehaviour) ? "class-" : "script-") + niceHelpNameForObject;
                content.tooltip = string.Format("Could not find Reference page for {0} ({1}).\nDocs for this object is missing or all docs are missing.\nThis warning only shows up in development builds.", niceHelpNameForObject, str2);
            }
            else
            {
                content.tooltip = string.Format("Open Reference for {0}.", niceHelpNameForObject);
            }
            if (GUI.Button(position, content, EditorStyles.inspectorTitlebarText))
            {
                Help.ShowHelpForObject(obj);
            }
            GUI.color = color;
            return true;
        }

        internal static bool IconButton(int id, Rect position, GUIContent content, GUIStyle style)
        {
            GUIUtility.CheckOnGUI();
            switch (Event.current.GetTypeForControl(id))
            {
                case EventType.MouseDown:
                    if (!position.Contains(Event.current.mousePosition))
                    {
                        return false;
                    }
                    GUIUtility.hotControl = id;
                    Event.current.Use();
                    return true;

                case EventType.MouseUp:
                    if (GUIUtility.hotControl != id)
                    {
                        return false;
                    }
                    GUIUtility.hotControl = 0;
                    Event.current.Use();
                    return position.Contains(Event.current.mousePosition);

                case EventType.MouseDrag:
                    if (!position.Contains(Event.current.mousePosition))
                    {
                        break;
                    }
                    GUIUtility.hotControl = id;
                    Event.current.Use();
                    return true;

                case EventType.Repaint:
                    style.Draw(position, content, id);
                    break;
            }
            return false;
        }

        public static Rect IndentedRect(Rect source)
        {
            float indent = EditorGUI.indent;
            return new Rect(source.x + indent, source.y, source.width - indent, source.height);
        }

        public static bool InspectorTitlebar(Rect position, bool foldout, UnityEngine.Object targetObj)
        {
            UnityEngine.Object[] targetObjs = new UnityEngine.Object[] { targetObj };
            return InspectorTitlebar(position, foldout, targetObjs);
        }

        public static bool InspectorTitlebar(Rect position, bool foldout, UnityEngine.Object[] targetObjs)
        {
            if (s_TitleSettingsIcon == null)
            {
                s_TitleSettingsIcon = EditorGUIUtility.IconContent("_Popup");
            }
            GUIStyle inspectorTitlebar = EditorStyles.inspectorTitlebar;
            GUIStyle inspectorTitlebarText = EditorStyles.inspectorTitlebarText;
            Rect rect = new Rect(position.x + inspectorTitlebar.padding.left, position.y + inspectorTitlebar.padding.top, 16f, 16f);
            Rect rect2 = new Rect(((position.xMax - inspectorTitlebar.padding.right) - 2f) - 16f, rect.y, 16f, 16f);
            Rect rect3 = new Rect(((rect.xMax + 2f) + 2f) + 16f, rect.y, 100f, rect.height) {
                xMax = rect2.xMin - 2f
            };
            int num = -1;
            foreach (UnityEngine.Object obj2 in targetObjs)
            {
                int objectEnabled = EditorUtility.GetObjectEnabled(obj2);
                if (num == -1)
                {
                    num = objectEnabled;
                }
                else if (num != objectEnabled)
                {
                    num = -2;
                }
            }
            if (num != -1)
            {
                bool flag = num != 0;
                showMixedValue = num == -2;
                Rect rect4 = rect;
                rect4.x = rect.xMax + 2f;
                BeginChangeCheck();
                flag = Toggle(rect4, flag);
                if (EndChangeCheck())
                {
                    Undo.RegisterUndo(targetObjs, (!flag ? "Disable" : "Enable") + " Component" + ((targetObjs.Length <= 1) ? string.Empty : "s"));
                    foreach (UnityEngine.Object obj3 in targetObjs)
                    {
                        EditorUtility.SetObjectEnabled(obj3, flag);
                    }
                }
                showMixedValue = false;
            }
            Rect rect5 = rect2;
            rect5.x -= 18f;
            if (HelpIconButton(rect5, targetObjs[0]))
            {
                rect3.xMax = rect5.xMin - 2f;
            }
            Event current = Event.current;
            Texture2D i = null;
            if (current.type == EventType.Repaint)
            {
                i = AssetPreview.GetMiniThumbnail(targetObjs[0]);
            }
            if ((ButtonMouseDown(rect, EditorGUIUtility.TempContent(i), FocusType.Passive, GUIStyle.none) && (targetObjs[0] is MonoScript)) && IconSelector.ShowAtPosition(targetObjs[0], new Vector2(rect.x, (rect.y + rect.height) + 2f), true))
            {
                GUIUtility.ExitGUI();
            }
            int controlID = GUIUtility.GetControlID(s_TitlebarHash, FocusType.Native, position);
            switch (current.type)
            {
                case EventType.MouseDown:
                    if (rect2.Contains(current.mousePosition) && (targetObjs[0] != null))
                    {
                        EditorUtility.DisplayObjectContextMenu(rect2, targetObjs, 0);
                        current.Use();
                    }
                    break;

                case EventType.Repaint:
                    inspectorTitlebar.Draw(position, GUIContent.none, controlID, foldout);
                    position = inspectorTitlebar.padding.Remove(position);
                    inspectorTitlebarText.Draw(rect3, EditorGUIUtility.TempContent(ObjectNames.GetInspectorTitle(targetObjs[0])), controlID, foldout);
                    if (targetObjs[0] != null)
                    {
                        inspectorTitlebarText.Draw(rect2, s_TitleSettingsIcon, controlID, foldout);
                    }
                    break;
            }
            return DoObjectFoldout(controlID, position, targetObjs, foldout);
        }

        public static int IntField(Rect position, int value)
        {
            GUIStyle numberField = EditorStyles.numberField;
            return IntField(position, value, numberField);
        }

        public static int IntField(Rect position, int value, GUIStyle style)
        {
            int id = GetControlID(s_FloatFieldHash, FocusType.Keyboard, position);
            return DoIntField(s_RecycledEditor, IndentedRect(position), new Rect(0f, 0f, 0f, 0f), id, value, kIntFieldFormatString, style, false, CalculateIntDragSensitivity(value));
        }

        public static int IntField(Rect position, string label, int value)
        {
            GUIStyle numberField = EditorStyles.numberField;
            return IntField(position, label, value, numberField);
        }

        public static int IntField(Rect position, GUIContent label, int value)
        {
            GUIStyle numberField = EditorStyles.numberField;
            return IntField(position, label, value, numberField);
        }

        public static int IntField(Rect position, string label, int value, GUIStyle style)
        {
            return IntField(position, EditorGUIUtility.TempContent(label), value, style);
        }

        public static int IntField(Rect position, GUIContent label, int value, GUIStyle style)
        {
            int id = GetControlID(s_FloatFieldHash, FocusType.Keyboard, position);
            Rect rect = PrefixLabel(position, id, label);
            position.xMax = rect.x;
            return DoIntField(s_RecycledEditor, rect, position, id, value, kIntFieldFormatString, style, true, CalculateIntDragSensitivity(value));
        }

        public static int IntPopup(Rect position, int selectedValue, string[] displayedOptions, int[] optionValues)
        {
            GUIStyle popup = EditorStyles.popup;
            return IntPopup(position, selectedValue, displayedOptions, optionValues, popup);
        }

        public static int IntPopup(Rect position, int selectedValue, GUIContent[] displayedOptions, int[] optionValues)
        {
            GUIStyle popup = EditorStyles.popup;
            return IntPopup(position, selectedValue, displayedOptions, optionValues, popup);
        }

        public static void IntPopup(Rect position, SerializedProperty property, GUIContent[] displayedOptions, int[] optionValues)
        {
            GUIContent label = null;
            IntPopup(position, property, displayedOptions, optionValues, label);
        }

        public static int IntPopup(Rect position, int selectedValue, string[] displayedOptions, int[] optionValues, GUIStyle style)
        {
            return IntPopup(position, selectedValue, EditorGUIUtility.TempContent(displayedOptions), optionValues, style);
        }

        public static int IntPopup(Rect position, int selectedValue, GUIContent[] displayedOptions, int[] optionValues, GUIStyle style)
        {
            int num;
            if (optionValues != null)
            {
                for (num = 0; (num < optionValues.Length) && (selectedValue != optionValues[num]); num++)
                {
                }
            }
            else
            {
                num = selectedValue;
            }
            num = Popup(position, num, displayedOptions, style);
            if (optionValues == null)
            {
                return num;
            }
            if ((num >= 0) && (num < optionValues.Length))
            {
                return optionValues[num];
            }
            return selectedValue;
        }

        public static int IntPopup(Rect position, string label, int selectedValue, string[] displayedOptions, int[] optionValues)
        {
            GUIStyle popup = EditorStyles.popup;
            return IntPopup(position, label, selectedValue, displayedOptions, optionValues, popup);
        }

        public static void IntPopup(Rect position, SerializedProperty property, GUIContent[] displayedOptions, int[] optionValues, GUIContent label)
        {
            label = BeginProperty(position, label, property);
            BeginChangeCheck();
            int num = IntPopup(position, label, property.intValue, displayedOptions, optionValues);
            if (EndChangeCheck())
            {
                property.intValue = num;
            }
            EndProperty();
        }

        public static int IntPopup(Rect position, GUIContent label, int selectedValue, GUIContent[] displayedOptions, int[] optionValues)
        {
            GUIStyle popup = EditorStyles.popup;
            return IntPopup(position, label, selectedValue, displayedOptions, optionValues, popup);
        }

        public static int IntPopup(Rect position, string label, int selectedValue, string[] displayedOptions, int[] optionValues, GUIStyle style)
        {
            return IntPopup(position, EditorGUIUtility.TempContent(label), selectedValue, EditorGUIUtility.TempContent(displayedOptions), optionValues, style);
        }

        public static int IntPopup(Rect position, GUIContent label, int selectedValue, GUIContent[] displayedOptions, int[] optionValues, GUIStyle style)
        {
            int id = GetControlID(s_EnumField, EditorGUIUtility.native, position);
            position = PrefixLabel(position, id, label);
            return IntPopup(position, selectedValue, displayedOptions, optionValues, style);
        }

        public static int IntSlider(Rect position, int value, int leftValue, int rightValue)
        {
            int id = GetControlID(s_SliderHash, EditorGUIUtility.native, position);
            return Mathf.RoundToInt(DoSlider(IndentedRect(position), EditorGUIUtility.DragZoneRect(position), id, (float) value, (float) leftValue, (float) rightValue, kIntFieldFormatString));
        }

        public static void IntSlider(Rect position, SerializedProperty property, int leftValue, int rightValue)
        {
            IntSlider(position, property, leftValue, rightValue, property.displayName);
        }

        public static int IntSlider(Rect position, string label, int value, int leftValue, int rightValue)
        {
            return IntSlider(position, EditorGUIUtility.TempContent(label), value, leftValue, rightValue);
        }

        public static void IntSlider(Rect position, SerializedProperty property, int leftValue, int rightValue, string label)
        {
            IntSlider(position, property, leftValue, rightValue, EditorGUIUtility.TempContent(label));
        }

        public static void IntSlider(Rect position, SerializedProperty property, int leftValue, int rightValue, GUIContent label)
        {
            label = BeginProperty(position, label, property);
            BeginChangeCheck();
            int num = IntSlider(position, label, property.intValue, leftValue, rightValue);
            if (EndChangeCheck())
            {
                property.intValue = num;
            }
            EndProperty();
        }

        public static int IntSlider(Rect position, GUIContent label, int value, int leftValue, int rightValue)
        {
            int id = GetControlID(s_SliderHash, EditorGUIUtility.native, position);
            return Mathf.RoundToInt(DoSlider(PrefixLabel(position, id, label), EditorGUIUtility.DragZoneRect(position), id, (float) value, (float) leftValue, (float) rightValue, kIntFieldFormatString));
        }

        internal static bool IsEditingTextField()
        {
            return RecycledTextEditor.s_ActuallyEditing;
        }

        internal static Event KeyEventField(Rect position, Event evt)
        {
            return DoKeyEventField(position, evt, GUI.skin.textField);
        }

        public static void LabelField(Rect position, string label)
        {
            GUIStyle style = EditorStyles.label;
            LabelField(position, label, style);
        }

        public static void LabelField(Rect position, GUIContent label)
        {
            GUIStyle style = EditorStyles.label;
            LabelField(position, label, style);
        }

        public static void LabelField(Rect position, string label, string label2)
        {
            GUIStyle style = EditorStyles.label;
            LabelField(position, label, label2, style);
        }

        public static void LabelField(Rect position, string label, GUIStyle style)
        {
            LabelField(position, GUIContent.none, EditorGUIUtility.TempContent(label), style);
        }

        public static void LabelField(Rect position, GUIContent label, GUIContent label2)
        {
            GUIStyle style = EditorStyles.label;
            LabelField(position, label, label2, style);
        }

        public static void LabelField(Rect position, GUIContent label, GUIStyle style)
        {
            LabelField(position, GUIContent.none, label, style);
        }

        public static void LabelField(Rect position, string label, string label2, GUIStyle style)
        {
            LabelField(position, new GUIContent(label), EditorGUIUtility.TempContent(label2), style);
        }

        public static void LabelField(Rect position, GUIContent label, GUIContent label2, GUIStyle style)
        {
            int id = GetControlID(s_FloatFieldHash, FocusType.Keyboard, position);
            position = PrefixLabel(position, id, label);
            if (Event.current.type == EventType.Repaint)
            {
                style.Draw(position, label2, id);
            }
        }

        internal static bool LabelHasContent(GUIContent label)
        {
            return ((label == null) || ((label.text != string.Empty) || (label.image != null)));
        }

        public static int LayerField(Rect position, int layer)
        {
            GUIStyle popup = EditorStyles.popup;
            return LayerField(position, layer, popup);
        }

        public static int LayerField(Rect position, int layer, GUIStyle style)
        {
            return LayerField(position, GUIContent.none, layer, style);
        }

        public static int LayerField(Rect position, string label, int layer)
        {
            GUIStyle popup = EditorStyles.popup;
            return LayerField(position, label, layer, popup);
        }

        public static int LayerField(Rect position, GUIContent label, int layer)
        {
            GUIStyle popup = EditorStyles.popup;
            return LayerField(position, label, layer, popup);
        }

        public static int LayerField(Rect position, string label, int layer, GUIStyle style)
        {
            return LayerField(position, EditorGUIUtility.TempContent(label), layer, style);
        }

        public static int LayerField(Rect position, GUIContent label, int layer, GUIStyle style)
        {
            int controlID = GetControlID(s_TagFieldHash, EditorGUIUtility.native, position);
            bool changed = GUI.changed;
            int selectedValueForControl = PopupCallbackInfo.GetSelectedValueForControl(controlID, -1);
            if (selectedValueForControl != -1)
            {
                if (selectedValueForControl >= InternalEditorUtility.layers.Length)
                {
                    Selection.activeObject = EditorApplication.tagManager;
                    GUI.changed = changed;
                }
                else
                {
                    int num3 = 0;
                    for (int j = 0; j < 0x20; j++)
                    {
                        if (InternalEditorUtility.GetLayerName(j).Length != 0)
                        {
                            if (num3 == selectedValueForControl)
                            {
                                layer = j;
                                break;
                            }
                            num3++;
                        }
                    }
                }
            }
            if ((Event.current.type != EventType.MouseDown) || !position.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.Repaint)
                {
                    style.Draw(PrefixLabel(position, controlID, label), InternalEditorUtility.GetLayerName(layer), false, false, false, false);
                }
                return layer;
            }
            int selected = 0;
            for (int i = 0; i < 0x20; i++)
            {
                if (InternalEditorUtility.GetLayerName(i).Length != 0)
                {
                    if (i == layer)
                    {
                        break;
                    }
                    selected++;
                }
            }
            string[] layers = InternalEditorUtility.layers;
            ArrayUtility.Add<string>(ref layers, string.Empty);
            ArrayUtility.Add<string>(ref layers, "Add Layer...");
            DoPopup(PrefixLabel(position, controlID, label), controlID, selected, EditorGUIUtility.TempContent(layers), style);
            return layer;
        }

        internal static void LayerMaskField(Rect position, SerializedProperty property, GUIContent label)
        {
            LayerMaskField(position, property, label, EditorStyles.layerMaskField);
        }

        internal static void LayerMaskField(Rect position, SerializedProperty property, GUIContent label, GUIStyle style)
        {
            int id = GetControlID(s_LayerMaskField, EditorGUIUtility.native, position);
            position = PrefixLabel(position, id, label);
            if (Event.current.type == EventType.Repaint)
            {
                if (showMixedValue)
                {
                    BeginHandleMixedValueContentColor();
                    style.Draw(position, s_MixedValueContent, id, false);
                    EndHandleMixedValueContentColor();
                }
                else
                {
                    style.Draw(position, EditorGUIUtility.TempContent(property.layerMaskStringValue), id, false);
                }
            }
            else if ((Event.current.type == EventType.MouseDown) && position.Contains(Event.current.mousePosition))
            {
                SerializedProperty userData = property.serializedObject.FindProperty(property.propertyPath);
                EditorUtility.DisplayCustomMenu(position, property.GetLayerMaskNames(), !property.hasMultipleDifferentValues ? property.GetLayerMaskSelectedIndex() : new int[0], new EditorUtility.SelectMenuItemFunction(EditorGUI.SetLayerMaskValueDelegate), userData);
                Event.current.Use();
            }
        }

        public static int MaskField(Rect position, int mask, string[] displayedOptions)
        {
            GUIStyle popup = EditorStyles.popup;
            return MaskField(position, mask, displayedOptions, popup);
        }

        public static int MaskField(Rect position, int mask, string[] displayedOptions, GUIStyle style)
        {
            int controlID = GetControlID(s_MaskField, EditorGUIUtility.native, position);
            return MaskFieldGUI.DoMaskField(IndentedRect(position), controlID, mask, displayedOptions, style);
        }

        public static int MaskField(Rect position, string label, int mask, string[] displayedOptions)
        {
            GUIStyle popup = EditorStyles.popup;
            return MaskField(position, label, mask, displayedOptions, popup);
        }

        public static int MaskField(Rect position, GUIContent label, int mask, string[] displayedOptions)
        {
            GUIStyle popup = EditorStyles.popup;
            return MaskField(position, label, mask, displayedOptions, popup);
        }

        public static int MaskField(Rect position, string label, int mask, string[] displayedOptions, GUIStyle style)
        {
            return MaskField(position, GUIContent.Temp(label), mask, displayedOptions, style);
        }

        public static int MaskField(Rect position, GUIContent label, int mask, string[] displayedOptions, GUIStyle style)
        {
            int id = GetControlID(s_MaskField, EditorGUIUtility.native, position);
            position = PrefixLabel(position, id, label);
            return MaskFieldGUI.DoMaskField(position, id, mask, displayedOptions, style);
        }

        public static void MinMaxSlider(Rect position, ref float minValue, ref float maxValue, float minLimit, float maxLimit)
        {
            DoMinMaxSlider(IndentedRect(position), GUIUtility.GetControlID(s_MinMaxSliderHash, FocusType.Native), ref minValue, ref maxValue, minLimit, maxLimit);
        }

        public static void MinMaxSlider(GUIContent label, Rect position, ref float minValue, ref float maxValue, float minLimit, float maxLimit)
        {
            int controlID = GUIUtility.GetControlID(s_MinMaxSliderHash, FocusType.Native);
            DoMinMaxSlider(PrefixLabel(position, controlID, label), controlID, ref minValue, ref maxValue, minLimit, maxLimit);
        }

        internal static Vector2 MouseDeltaReader(Rect position, bool activated)
        {
            int controlID = GetControlID(s_MouseDeltaReaderHash, FocusType.Passive, position);
            Event current = Event.current;
            switch (current.GetTypeForControl(controlID))
            {
                case EventType.MouseDown:
                    if ((activated && (GUIUtility.hotControl == 0)) && (position.Contains(current.mousePosition) && (current.button == 0)))
                    {
                        GUIUtility.hotControl = controlID;
                        GUIUtility.keyboardControl = 0;
                        s_MouseDeltaReaderLastPos = GUIClip.Unclip(current.mousePosition);
                        current.Use();
                    }
                    break;

                case EventType.MouseUp:
                    if ((GUIUtility.hotControl == controlID) && (current.button == 0))
                    {
                        GUIUtility.hotControl = 0;
                        current.Use();
                    }
                    break;

                case EventType.MouseDrag:
                {
                    if (GUIUtility.hotControl != controlID)
                    {
                        break;
                    }
                    Vector2 vector = GUIClip.Unclip(current.mousePosition);
                    Vector2 vector2 = vector - s_MouseDeltaReaderLastPos;
                    s_MouseDeltaReaderLastPos = vector;
                    current.Use();
                    return vector2;
                }
            }
            return Vector2.zero;
        }

        internal static void MultiField(Rect position, GUIContent[] labels, SerializedProperty valuesIterator)
        {
            MultiField(position, labels, valuesIterator, GetMultiFieldLabelWidth(labels.Length));
        }

        internal static void MultiField(Rect position, GUIContent[] labels, float[] values)
        {
            MultiField(position, labels, values, GetMultiFieldLabelWidth(labels.Length));
        }

        internal static void MultiField(Rect position, GUIContent[] labels, SerializedProperty valuesIterator, float labelWidth)
        {
            position = IndentedRect(position);
            int length = labels.Length;
            float num2 = (position.width - ((length - 1) * 5f)) / ((float) length);
            Rect rect = new Rect(position) {
                width = num2
            };
            float num3 = EditorGUIUtility.labelWidth;
            int indentLevel = EditorGUI.indentLevel;
            EditorGUIUtility.labelWidth = labelWidth;
            EditorGUI.indentLevel = 0;
            for (int i = 0; i < length; i++)
            {
                PropertyField(rect, valuesIterator, labels[i]);
                rect.x += num2 + 5f;
                valuesIterator.NextVisible(false);
            }
            EditorGUIUtility.labelWidth = num3;
            EditorGUI.indentLevel = indentLevel;
        }

        internal static void MultiField(Rect position, GUIContent[] labels, float[] values, float labelWidth)
        {
            position = IndentedRect(position);
            int length = values.Length;
            float num2 = (position.width - ((length - 1) * 5f)) / ((float) length);
            Rect rect = new Rect(position) {
                width = num2
            };
            float num3 = EditorGUIUtility.labelWidth;
            int indentLevel = EditorGUI.indentLevel;
            EditorGUIUtility.labelWidth = labelWidth;
            EditorGUI.indentLevel = 0;
            for (int i = 0; i < values.Length; i++)
            {
                values[i] = FloatField(rect, labels[i], values[i]);
                rect.x += num2 + 5f;
            }
            EditorGUIUtility.labelWidth = num3;
            EditorGUI.indentLevel = indentLevel;
        }

        [Obsolete("Check the docs for the usage of the new parameter 'allowSceneObjects'.")]
        public static UnityEngine.Object ObjectField(Rect position, UnityEngine.Object obj, System.Type objType)
        {
            int id = GetControlID(s_ObjectFieldHash, EditorGUIUtility.native, position);
            return DoObjectField(position, position, id, obj, objType, null, null, true);
        }

        [Obsolete("Check the docs for the usage of the new parameter 'allowSceneObjects'.")]
        public static UnityEngine.Object ObjectField(Rect position, string label, UnityEngine.Object obj, System.Type objType)
        {
            return ObjectField(position, EditorGUIUtility.TempContent(label), obj, objType, true);
        }

        [Obsolete("Check the docs for the usage of the new parameter 'allowSceneObjects'.")]
        public static UnityEngine.Object ObjectField(Rect position, GUIContent label, UnityEngine.Object obj, System.Type objType)
        {
            int id = GetControlID(s_ObjectFieldHash, EditorGUIUtility.native, position);
            Rect rect = PrefixLabel(position, id, label);
            return DoObjectField(rect, !EditorGUIUtility.lookLikeInspector ? rect : position, id, obj, objType, null, null, true);
        }

        public static UnityEngine.Object ObjectField(Rect position, UnityEngine.Object obj, System.Type objType, bool allowSceneObjects)
        {
            int id = GetControlID(s_ObjectFieldHash, EditorGUIUtility.native, position);
            return DoObjectField(IndentedRect(position), IndentedRect(position), id, obj, objType, null, null, allowSceneObjects);
        }

        public static UnityEngine.Object ObjectField(Rect position, string label, UnityEngine.Object obj, System.Type objType, bool allowSceneObjects)
        {
            return ObjectField(position, EditorGUIUtility.TempContent(label), obj, objType, allowSceneObjects);
        }

        public static UnityEngine.Object ObjectField(Rect position, GUIContent label, UnityEngine.Object obj, System.Type objType, bool allowSceneObjects)
        {
            int id = GetControlID(s_ObjectFieldHash, EditorGUIUtility.native, position);
            Rect rect = PrefixLabel(position, id, label);
            return DoObjectField(rect, !EditorGUIUtility.lookLikeInspector ? rect : position, id, obj, objType, null, null, allowSceneObjects);
        }

        internal static void ObjectIconDropDown(Rect position, UnityEngine.Object[] targets, bool showLabelIcons, Texture2D nullIcon, SerializedProperty iconProperty)
        {
            if (s_IconTextureInactive == null)
            {
                s_IconTextureInactive = (Material) EditorGUIUtility.LoadRequired("Inspectors/InactiveGUI.mat");
            }
            if (Event.current.type == EventType.Repaint)
            {
                Texture2D texture = null;
                if (!iconProperty.hasMultipleDifferentValues)
                {
                    texture = AssetPreview.GetMiniThumbnail(targets[0]);
                }
                if (texture == null)
                {
                    texture = nullIcon;
                }
                Vector2 vector = new Vector2(position.width, position.height);
                if (texture != null)
                {
                    vector.x = Mathf.Min((float) texture.width, vector.x);
                    vector.y = Mathf.Min((float) texture.height, vector.y);
                }
                Rect screenRect = new Rect((position.x + (position.width / 2f)) - (vector.x / 2f), (position.y + (position.height / 2f)) - (vector.y / 2f), vector.x, vector.y);
                GameObject obj2 = targets[0] as GameObject;
                if ((obj2 != null) && (!EditorUtility.IsPersistent(targets[0]) && (!obj2.activeSelf || !obj2.activeInHierarchy)))
                {
                    Graphics.DrawTexture(screenRect, texture, new Rect(0f, 0f, 1f, 1f), 0, 0, 0, 0, new Color(0.5f, 0.5f, 0.5f, 1f), s_IconTextureInactive);
                }
                else
                {
                    GUI.DrawTexture(screenRect, texture);
                }
                if (ValidTargetForIconSelection(targets))
                {
                    if (s_IconDropDown == null)
                    {
                        s_IconDropDown = EditorGUIUtility.IconContent("Icon Dropdown");
                    }
                    float left = Mathf.Max((float) (position.x + 2f), (float) (screenRect.x - 6f));
                    GUIStyle.none.Draw(new Rect(left, screenRect.yMax - (screenRect.height * 0.2f), 13f, 8f), s_IconDropDown, false, false, false, false);
                }
            }
            if ((ButtonMouseDown(position, GUIContent.none, FocusType.Passive, GUIStyle.none) && ValidTargetForIconSelection(targets)) && IconSelector.ShowAtPosition(targets[0], new Vector2(position.x, position.yMax + 2f), showLabelIcons))
            {
                GUIUtility.ExitGUI();
            }
        }

        internal static void ObjectReferenceField(Rect position, SerializedProperty property, GUIContent label)
        {
            ObjectReferenceField(position, property, label, EditorStyles.objectField);
        }

        internal static void ObjectReferenceField(Rect position, SerializedProperty property, GUIContent label, GUIStyle style)
        {
            Rect rect;
            int id = GetControlID(s_PPtrHash, EditorGUIUtility.native, position);
            if ((label == null) || (label == GUIContent.none))
            {
                rect = position;
            }
            else
            {
                rect = PrefixLabel(position, id, label);
            }
            bool allowSceneObjects = false;
            if (property != null)
            {
                UnityEngine.Object targetObject = property.serializedObject.targetObject;
                if ((targetObject != null) && !EditorUtility.IsPersistent(targetObject))
                {
                    allowSceneObjects = true;
                }
            }
            DoObjectField(rect, !EditorGUIUtility.lookLikeInspector ? rect : position, id, null, null, property, null, allowSceneObjects, style);
        }

        public static string PasswordField(Rect position, string password)
        {
            GUIStyle textField = EditorStyles.textField;
            return PasswordField(position, password, textField);
        }

        public static string PasswordField(Rect position, string label, string password)
        {
            GUIStyle textField = EditorStyles.textField;
            return PasswordField(position, label, password, textField);
        }

        public static string PasswordField(Rect position, string password, GUIStyle style)
        {
            return DoPasswordField(GetControlID(s_PasswordFieldHash, FocusType.Keyboard, position), IndentedRect(position), password, style);
        }

        public static string PasswordField(Rect position, GUIContent label, string password)
        {
            GUIStyle textField = EditorStyles.textField;
            return PasswordField(position, label, password, textField);
        }

        public static string PasswordField(Rect position, string label, string password, GUIStyle style)
        {
            return PasswordField(position, EditorGUIUtility.TempContent(label), password, style);
        }

        public static string PasswordField(Rect position, GUIContent label, string password, GUIStyle style)
        {
            return DoPasswordField(GetControlID(s_PasswordFieldHash, FocusType.Keyboard, position), position, label, password, style);
        }

        public static int Popup(Rect position, int selectedIndex, string[] displayedOptions)
        {
            GUIStyle popup = EditorStyles.popup;
            return Popup(position, selectedIndex, displayedOptions, popup);
        }

        public static int Popup(Rect position, int selectedIndex, GUIContent[] displayedOptions)
        {
            GUIStyle popup = EditorStyles.popup;
            return Popup(position, selectedIndex, displayedOptions, popup);
        }

        private static void Popup(Rect position, SerializedProperty property, GUIContent label)
        {
            BeginChangeCheck();
            int num = Popup(position, label, !property.hasMultipleDifferentValues ? property.enumValueIndex : -1, EditorGUIUtility.TempContent(property.enumNames));
            if (EndChangeCheck())
            {
                property.enumValueIndex = num;
            }
        }

        public static int Popup(Rect position, int selectedIndex, string[] displayedOptions, GUIStyle style)
        {
            return DoPopup(IndentedRect(position), GetControlID(s_PopupHash, EditorGUIUtility.native, position), selectedIndex, EditorGUIUtility.TempContent(displayedOptions), style);
        }

        public static int Popup(Rect position, int selectedIndex, GUIContent[] displayedOptions, GUIStyle style)
        {
            return DoPopup(IndentedRect(position), GetControlID(s_PopupHash, EditorGUIUtility.native, position), selectedIndex, displayedOptions, style);
        }

        public static int Popup(Rect position, string label, int selectedIndex, string[] displayedOptions)
        {
            GUIStyle popup = EditorStyles.popup;
            return Popup(position, label, selectedIndex, displayedOptions, popup);
        }

        internal static void Popup(Rect position, SerializedProperty property, GUIContent[] displayedOptions, GUIContent label)
        {
            label = BeginProperty(position, label, property);
            BeginChangeCheck();
            int num = Popup(position, label, !property.hasMultipleDifferentValues ? property.intValue : -1, displayedOptions);
            if (EndChangeCheck())
            {
                property.intValue = num;
            }
            EndProperty();
        }

        public static int Popup(Rect position, GUIContent label, int selectedIndex, GUIContent[] displayedOptions)
        {
            GUIStyle popup = EditorStyles.popup;
            return Popup(position, label, selectedIndex, displayedOptions, popup);
        }

        public static int Popup(Rect position, string label, int selectedIndex, string[] displayedOptions, GUIStyle style)
        {
            return Popup(position, EditorGUIUtility.TempContent(label), selectedIndex, EditorGUIUtility.TempContent(displayedOptions), style);
        }

        public static int Popup(Rect position, GUIContent label, int selectedIndex, GUIContent[] displayedOptions, GUIStyle style)
        {
            int controlID = GetControlID(s_PopupHash, EditorGUIUtility.native, position);
            return DoPopup(PrefixLabel(position, controlID, label), controlID, selectedIndex, displayedOptions, style);
        }

        internal static float PowerSlider(Rect position, float sliderValue, float min, float max, float power)
        {
            float leftValue = PowPreserveSign(min, 1f / power);
            float rightValue = PowPreserveSign(max, 1f / power);
            float num3 = PowPreserveSign(sliderValue, 1f / power);
            BeginChangeCheck();
            num3 = PowPreserveSign(GUI.HorizontalSlider(position, num3, leftValue, rightValue), power);
            if (!EndChangeCheck())
            {
                num3 = sliderValue;
            }
            return num3;
        }

        private static float PowPreserveSign(float f, float p)
        {
            float num = Mathf.Pow(Mathf.Abs(f), p);
            return ((f >= 0f) ? num : -num);
        }

        public static Rect PrefixLabel(Rect totalPosition, int id, GUIContent label)
        {
            if (!LabelHasContent(label))
            {
                return IndentedRect(totalPosition);
            }
            float labelWidth = EditorGUIUtility.labelWidth;
            switch (Event.current.type)
            {
                case EventType.MouseDown:
                    if (Event.current.button == 0)
                    {
                        Rect rect = new Rect(totalPosition.x + indent, totalPosition.y, labelWidth - indent, totalPosition.height);
                        if (rect.Contains(Event.current.mousePosition))
                        {
                            GUIUtility.keyboardControl = id;
                            RecycledTextEditor.s_ActuallyEditing = false;
                            HandleUtility.Repaint();
                        }
                    }
                    break;

                case EventType.Repaint:
                    EditorStyles.label.Draw(new Rect(totalPosition.x + indent, totalPosition.y, labelWidth - indent, totalPosition.height), label, id);
                    break;
            }
            return new Rect(totalPosition.x + labelWidth, totalPosition.y, totalPosition.width - labelWidth, totalPosition.height);
        }

        public static void ProgressBar(Rect position, float value, string text)
        {
            int controlID = GetControlID(s_ProgressBarHash, EditorGUIUtility.native, position);
            if (Event.current.GetTypeForControl(controlID) == EventType.Repaint)
            {
                EditorStyles.progressBarBack.Draw(position, false, false, false, false);
                Rect rect = new Rect(position);
                value = Mathf.Clamp01(value);
                rect.width *= value;
                EditorStyles.progressBarBar.Draw(rect, false, false, false, false);
                EditorStyles.progressBarText.Draw(position, text, false, false, false, false);
            }
        }

        public static bool PropertyField(Rect position, SerializedProperty property)
        {
            bool includeChildren = false;
            return PropertyField(position, property, includeChildren);
        }

        public static bool PropertyField(Rect position, SerializedProperty property, bool includeChildren)
        {
            return PropertyField(position, property, null, includeChildren);
        }

        public static bool PropertyField(Rect position, SerializedProperty property, GUIContent label)
        {
            bool includeChildren = false;
            return PropertyField(position, property, label, includeChildren);
        }

        public static bool PropertyField(Rect position, SerializedProperty property, GUIContent label, bool includeChildren)
        {
            if (!includeChildren)
            {
                return SinglePropertyField(position, property, label);
            }
            Vector2 iconSize = EditorGUIUtility.GetIconSize();
            if (EditorGUIUtility.lookLikeInspector)
            {
                EditorGUIUtility.SetIconSize(new Vector2(16f, 16f));
            }
            bool enabled = GUI.enabled;
            int indentLevel = EditorGUI.indentLevel;
            int num2 = indentLevel - property.depth;
            position.height = 16f;
            SerializedProperty property2 = property.Copy();
            SerializedProperty endProperty = property2.GetEndProperty();
            EditorGUI.indentLevel = property2.depth + num2;
            bool enterChildren = SinglePropertyField(position, property2, label) && HasVisibleChildFields(property2);
            position.y += GetSinglePropertyHeight(property2);
            while (property2.NextVisible(enterChildren) && !SerializedProperty.EqualContents(property2, endProperty))
            {
                EditorGUI.indentLevel = property2.depth + num2;
                BeginChangeCheck();
                enterChildren = SinglePropertyField(position, property2) && HasVisibleChildFields(property2);
                if (EndChangeCheck())
                {
                    break;
                }
                position.y += GetSinglePropertyHeight(property2);
            }
            GUI.enabled = enabled;
            EditorGUIUtility.SetIconSize(iconSize);
            EditorGUI.indentLevel = indentLevel;
            return false;
        }

        public static Rect RectField(Rect position, Rect value)
        {
            position.height = 16f;
            s_Vector2Floats[0] = value.x;
            s_Vector2Floats[1] = value.y;
            BeginChangeCheck();
            MultiField(position, s_XYLabels, s_Vector2Floats);
            if (EndChangeCheck())
            {
                value.x = s_Vector2Floats[0];
                value.y = s_Vector2Floats[1];
            }
            position.y += 16f;
            s_Vector2Floats[0] = value.width;
            s_Vector2Floats[1] = value.height;
            BeginChangeCheck();
            MultiField(position, s_WHLabels, s_Vector2Floats);
            if (EndChangeCheck())
            {
                value.width = s_Vector2Floats[0];
                value.height = s_Vector2Floats[1];
            }
            return value;
        }

        public static Rect RectField(Rect position, string label, Rect value)
        {
            return RectField(position, EditorGUIUtility.TempContent(label), value);
        }

        private static void RectField(Rect position, SerializedProperty property, GUIContent label)
        {
            int num = ms_IndentLevel;
            if (LabelHasContent(label))
            {
                GUI.Label(IndentedRect(position), label, EditorStyles.label);
                position.y += 19f;
                ms_IndentLevel++;
            }
            position.height = 16f;
            SerializedProperty valuesIterator = property.Copy();
            valuesIterator.NextVisible(true);
            MultiField(position, s_XYLabels, valuesIterator);
            position.y += 16f;
            MultiField(position, s_WHLabels, valuesIterator);
            ms_IndentLevel = num;
        }

        public static Rect RectField(Rect position, GUIContent label, Rect value)
        {
            GUI.Label(IndentedRect(position), label, EditorStyles.label);
            position.y += 19f;
            ms_IndentLevel++;
            value = RectField(position, value);
            ms_IndentLevel--;
            return value;
        }

        internal static string SearchField(Rect position, string text)
        {
            bool flag;
            int id = GetControlID(s_SearchFieldHash, FocusType.Keyboard, position);
            Rect rect = position;
            rect.width -= 15f;
            text = DoTextField(s_RecycledEditor, id, rect, text, EditorStyles.searchField, null, out flag, false, false, false);
            Rect rect2 = position;
            rect2.x += position.width - 15f;
            rect2.width = 15f;
            if (GUI.Button(rect2, GUIContent.none, !(text != string.Empty) ? EditorStyles.searchFieldCancelButtonEmpty : EditorStyles.searchFieldCancelButton) && (text != string.Empty))
            {
                text = string.Empty;
                GUIUtility.keyboardControl = 0;
            }
            return text;
        }

        public static void SelectableLabel(Rect position, string text)
        {
            GUIStyle label = EditorStyles.label;
            SelectableLabel(position, text, label);
        }

        public static void SelectableLabel(Rect position, string text, GUIStyle style)
        {
            int num = GetControlID(s_SelectableLabelHash, FocusType.Keyboard, position);
            string name = "ControlName_" + num;
            Event current = Event.current;
            if ((current.type == EventType.KeyDown) && (GUI.GetNameOfFocusedControl() == name))
            {
                KeyCode keyCode = current.keyCode;
                switch (keyCode)
                {
                    case KeyCode.UpArrow:
                    case KeyCode.DownArrow:
                    case KeyCode.RightArrow:
                    case KeyCode.LeftArrow:
                    case KeyCode.Home:
                    case KeyCode.End:
                    case KeyCode.PageUp:
                    case KeyCode.PageDown:
                        goto Label_00B1;
                }
                switch (keyCode)
                {
                    case KeyCode.Space:
                        GUIUtility.hotControl = 0;
                        GUIUtility.keyboardControl = 0;
                        break;

                    case KeyCode.C:
                        break;

                    default:
                        current.Use();
                        break;
                }
            }
        Label_00B1:
            if (((current.type == EventType.ExecuteCommand) && ((current.commandName == "Paste") || (current.commandName == "Cut"))) && (GUI.GetNameOfFocusedControl() == name))
            {
                current.Use();
            }
            GUI.SetNextControlName(name);
            Color cursorColor = GUI.skin.settings.cursorColor;
            GUI.skin.settings.cursorColor = new Color(0f, 0f, 0f, 0f);
            RecycledTextEditor.s_AllowContextCutOrPaste = false;
            TextArea(position, text, style);
            GUI.skin.settings.cursorColor = cursorColor;
        }

        private static void SetCurveEditorWindowCurve(AnimationCurve value, SerializedProperty property, Color color)
        {
            if (property != null)
            {
                CurveEditorWindow.curve = !property.hasMultipleDifferentValues ? property.animationCurveValue : new AnimationCurve();
            }
            else
            {
                CurveEditorWindow.curve = value;
            }
            CurveEditorWindow.color = color;
        }

        private static void SetExpandedRecurse(SerializedProperty property, bool expanded)
        {
            SerializedProperty property2 = property.Copy();
            property2.isExpanded = expanded;
            int depth = property2.depth;
            while (property2.NextVisible(true) && (property2.depth > depth))
            {
                if (property2.hasVisibleChildren)
                {
                    property2.isExpanded = expanded;
                }
            }
        }

        internal static void SetLayerMaskValueDelegate(object userData, string[] options, int selected)
        {
            SerializedProperty property = (SerializedProperty) userData;
            property.ToggleLayerMaskAtIndex(selected);
            property.serializedObject.ApplyModifiedProperties();
        }

        private static void ShowCurvePopup(GUIView viewToUpdate, Rect ranges)
        {
            CurveEditorSettings settings = new CurveEditorSettings();
            if (((ranges.width > 0f) && (ranges.height > 0f)) && ((ranges.width != float.PositiveInfinity) && (ranges.height != float.PositiveInfinity)))
            {
                settings.hRangeMin = ranges.xMin;
                settings.hRangeMax = ranges.xMax;
                settings.vRangeMin = ranges.yMin;
                settings.vRangeMax = ranges.yMax;
            }
            CurveEditorWindow.instance.Show(GUIView.current, settings);
        }

        internal static void ShowRepaints()
        {
            if (Unsupported.IsDeveloperBuild())
            {
                Color color = GUI.color;
                GUI.color = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value);
                GUI.Label(new Rect(0f, 0f, 10f, 10f), "i", "Button");
                GUI.color = color;
            }
        }

        private static void ShowTextEditorPopupMenu()
        {
            GenericMenu menu = new GenericMenu();
            if (s_RecycledEditor.hasSelection && !s_RecycledEditor.isPasswordField)
            {
                if (RecycledTextEditor.s_AllowContextCutOrPaste)
                {
                    menu.AddItem(EditorGUIUtility.TextContent("TextEditorPopup.Cut"), false, new GenericMenu.MenuFunction(new PopupMenuEvent("Cut", GUIView.current).SendEvent));
                }
                menu.AddItem(EditorGUIUtility.TextContent("TextEditorPopup.Copy"), false, new GenericMenu.MenuFunction(new PopupMenuEvent("Copy", GUIView.current).SendEvent));
            }
            else
            {
                if (RecycledTextEditor.s_AllowContextCutOrPaste)
                {
                    menu.AddDisabledItem(EditorGUIUtility.TextContent("TextEditorPopup.Cut"));
                }
                menu.AddDisabledItem(EditorGUIUtility.TextContent("TextEditorPopup.Copy"));
            }
            if (s_RecycledEditor.CanPaste() && RecycledTextEditor.s_AllowContextCutOrPaste)
            {
                menu.AddItem(EditorGUIUtility.TextContent("TextEditorPopup.Paste"), false, new GenericMenu.MenuFunction(new PopupMenuEvent("Paste", GUIView.current).SendEvent));
            }
            menu.ShowAsContext();
        }

        internal static bool SinglePropertyField(Rect position, SerializedProperty property)
        {
            GUIContent label = null;
            return SinglePropertyField(position, property, label);
        }

        internal static bool SinglePropertyField(Rect position, SerializedProperty property, GUIContent label)
        {
            PropertyDrawer drawer = PropertyDrawer.GetDrawer(property);
            if (drawer != null)
            {
                EditorLook look = EditorGUIUtility.look;
                float labelWidth = EditorGUIUtility.labelWidth;
                float kNumberW = EditorGUI.kNumberW;
                if (label == null)
                {
                }
                drawer.OnGUI(position, property.Copy(), EditorGUIUtility.TempContent(property.displayName));
                if (EditorGUIUtility.look != look)
                {
                    if (look == EditorLook.LikeControls)
                    {
                        EditorGUIUtility.LookLikeControls(labelWidth, kNumberW);
                    }
                    else
                    {
                        EditorGUIUtility.LookLikeInspector();
                    }
                }
                EditorGUIUtility.labelWidth = labelWidth;
                EditorGUI.kNumberW = kNumberW;
                return false;
            }
            label = BeginProperty(position, label, property);
            SerializedPropertyType propertyType = property.propertyType;
            bool foldout = false;
            if (HasVisibleChildFields(property))
            {
                int num9 = GetControlID(s_FoldoutHash, FocusType.Passive, position);
                EventType type = Event.current.type;
                switch (type)
                {
                    case EventType.DragUpdated:
                    case EventType.DragPerform:
                        if (position.Contains(Event.current.mousePosition) && GUI.enabled)
                        {
                            UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
                            UnityEngine.Object[] references = new UnityEngine.Object[1];
                            bool flag4 = false;
                            foreach (UnityEngine.Object obj2 in objectReferences)
                            {
                                references[0] = obj2;
                                UnityEngine.Object obj3 = ValidateObjectFieldAssignment(references, null, property);
                                if (obj3 != null)
                                {
                                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                                    if (Event.current.type == EventType.DragPerform)
                                    {
                                        property.AppendFoldoutPPtrValue(obj3);
                                        flag4 = true;
                                        DragAndDrop.activeControlID = 0;
                                    }
                                    else
                                    {
                                        DragAndDrop.activeControlID = num9;
                                    }
                                }
                            }
                            if (flag4)
                            {
                                GUI.changed = true;
                                DragAndDrop.AcceptDrag();
                                Event.current.Use();
                            }
                        }
                        goto Label_0442;
                }
                if ((type == EventType.DragExited) && GUI.enabled)
                {
                    HandleUtility.Repaint();
                }
            }
            else
            {
                bool changed;
                switch (propertyType)
                {
                    case SerializedPropertyType.Integer:
                    {
                        BeginChangeCheck();
                        int num3 = IntField(position, label, property.intValue);
                        if (EndChangeCheck())
                        {
                            property.intValue = num3;
                        }
                        goto Label_0508;
                    }
                    case SerializedPropertyType.Boolean:
                    {
                        BeginChangeCheck();
                        bool flag2 = Toggle(position, label, property.boolValue);
                        if (EndChangeCheck())
                        {
                            property.boolValue = flag2;
                        }
                        goto Label_0508;
                    }
                    case SerializedPropertyType.Float:
                    {
                        BeginChangeCheck();
                        float num4 = FloatField(position, label, property.floatValue);
                        if (EndChangeCheck())
                        {
                            property.floatValue = num4;
                        }
                        goto Label_0508;
                    }
                    case SerializedPropertyType.String:
                    {
                        BeginChangeCheck();
                        string str = TextField(position, label, property.stringValue);
                        if (EndChangeCheck())
                        {
                            property.stringValue = str;
                        }
                        goto Label_0508;
                    }
                    case SerializedPropertyType.Color:
                    {
                        BeginChangeCheck();
                        Color color = ColorField(position, label, property.colorValue);
                        if (EndChangeCheck())
                        {
                            property.colorValue = color;
                        }
                        goto Label_0508;
                    }
                    case SerializedPropertyType.ObjectReference:
                        ObjectReferenceField(position, property, label);
                        goto Label_0508;

                    case SerializedPropertyType.LayerMask:
                        LayerMaskField(position, property, label);
                        goto Label_0508;

                    case SerializedPropertyType.Enum:
                        Popup(position, property, label);
                        goto Label_0508;

                    case SerializedPropertyType.Vector3:
                        Vector3Field(position, property, label);
                        goto Label_0508;

                    case SerializedPropertyType.Rect:
                        RectField(position, property, label);
                        goto Label_0508;

                    case SerializedPropertyType.ArraySize:
                    {
                        BeginChangeCheck();
                        int num5 = ArraySizeField(position, label, property.intValue, EditorStyles.numberField);
                        if (EndChangeCheck())
                        {
                            property.intValue = num5;
                        }
                        goto Label_0508;
                    }
                    case SerializedPropertyType.Character:
                    {
                        char[] chArray = new char[] { (char) property.intValue };
                        changed = GUI.changed;
                        GUI.changed = false;
                        string str2 = TextField(position, label, new string(chArray));
                        if (GUI.changed)
                        {
                            if (str2.Length != 1)
                            {
                                GUI.changed = false;
                                break;
                            }
                            property.intValue = str2[0];
                        }
                        break;
                    }
                    case SerializedPropertyType.AnimationCurve:
                    {
                        int id = GetControlID(s_CurveHash, EditorGUIUtility.native, position);
                        DoCurveField(PrefixLabel(position, id, label), id, null, kCurveColor, new Rect(), property);
                        goto Label_0508;
                    }
                    case SerializedPropertyType.Bounds:
                        BoundsField(position, property, label);
                        goto Label_0508;

                    case SerializedPropertyType.Gradient:
                    {
                        int num7 = GetControlID(s_CurveHash, EditorGUIUtility.native, position);
                        DoGradientField(PrefixLabel(position, num7, label), num7, null, property);
                        goto Label_0508;
                    }
                    default:
                    {
                        int num8 = GetControlID(s_GenericField, FocusType.Keyboard, position);
                        PrefixLabel(position, num8, label);
                        goto Label_0508;
                    }
                }
                GUI.changed |= changed;
                goto Label_0508;
            }
        Label_0442:
            foldout = property.isExpanded;
            if (EditorGUIUtility.lookLikeInspector)
            {
                int num11 = EditorStyles.foldout.padding.left - EditorStyles.label.padding.left;
                position.x -= num11;
                position.width += num11;
            }
            GUI.enabled &= property.editable;
            GUIStyle style = (DragAndDrop.activeControlID != -10) ? EditorStyles.foldout : EditorStyles.foldoutPreDrop;
            bool expanded = Foldout(position, foldout, s_PropertyFieldTempContent, true, style);
            if (expanded != foldout)
            {
                if (Event.current.alt)
                {
                    SetExpandedRecurse(property, expanded);
                }
                else
                {
                    property.isExpanded = expanded;
                }
            }
            foldout = expanded;
        Label_0508:
            EndProperty();
            if ((Event.current.type == EventType.ExecuteCommand) || (Event.current.type == EventType.ValidateCommand))
            {
                if ((GUIUtility.keyboardControl == lastControlID) && ((Event.current.commandName == "Delete") || (Event.current.commandName == "SoftDelete")))
                {
                    if (Event.current.type == EventType.ExecuteCommand)
                    {
                        property.DeleteCommand();
                    }
                    Event.current.Use();
                }
                if ((GUIUtility.keyboardControl != lastControlID) || !(Event.current.commandName == "Duplicate"))
                {
                    return foldout;
                }
                if (Event.current.type == EventType.ExecuteCommand)
                {
                    property.DuplicateCommand();
                }
                Event.current.Use();
            }
            return foldout;
        }

        public static float Slider(Rect position, float value, float leftValue, float rightValue)
        {
            int id = GetControlID(s_SliderHash, EditorGUIUtility.native, position);
            return DoSlider(IndentedRect(position), EditorGUIUtility.DragZoneRect(position), id, value, leftValue, rightValue, kFloatFieldFormatString);
        }

        public static void Slider(Rect position, SerializedProperty property, float leftValue, float rightValue)
        {
            Slider(position, property, leftValue, rightValue, property.displayName);
        }

        public static float Slider(Rect position, string label, float value, float leftValue, float rightValue)
        {
            return Slider(position, EditorGUIUtility.TempContent(label), value, leftValue, rightValue);
        }

        public static void Slider(Rect position, SerializedProperty property, float leftValue, float rightValue, string label)
        {
            Slider(position, property, leftValue, rightValue, EditorGUIUtility.TempContent(label));
        }

        public static void Slider(Rect position, SerializedProperty property, float leftValue, float rightValue, GUIContent label)
        {
            label = BeginProperty(position, label, property);
            BeginChangeCheck();
            float num = Slider(position, label, property.floatValue, leftValue, rightValue);
            if (EndChangeCheck())
            {
                property.floatValue = num;
            }
            EndProperty();
        }

        public static float Slider(Rect position, GUIContent label, float value, float leftValue, float rightValue)
        {
            int id = GetControlID(s_SliderHash, EditorGUIUtility.native, position);
            return DoSlider(PrefixLabel(position, id, label), EditorGUIUtility.DragZoneRect(position), id, value, leftValue, rightValue, kFloatFieldFormatString);
        }

        public static string TagField(Rect position, string tag)
        {
            GUIStyle popup = EditorStyles.popup;
            return TagField(position, tag, popup);
        }

        public static string TagField(Rect position, string label, string tag)
        {
            GUIStyle popup = EditorStyles.popup;
            return TagField(position, label, tag, popup);
        }

        public static string TagField(Rect position, string tag, GUIStyle style)
        {
            position = IndentedRect(position);
            int controlID = GetControlID(s_TagFieldHash, EditorGUIUtility.native, position);
            int selectedValueForControl = PopupCallbackInfo.GetSelectedValueForControl(controlID, -1);
            if (selectedValueForControl != -1)
            {
                string[] strArray = InternalEditorUtility.tags;
                if (selectedValueForControl >= strArray.Length)
                {
                    Selection.activeObject = EditorApplication.tagManager;
                }
                else
                {
                    tag = strArray[selectedValueForControl];
                }
            }
            if ((Event.current.type != EventType.MouseDown) || !position.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.Repaint)
                {
                    BeginHandleMixedValueContentColor();
                    style.Draw(position, !showMixedValue ? tag : s_MixedValueContent.text, false, false, false, false);
                    EndHandleMixedValueContentColor();
                }
                return tag;
            }
            int index = 0;
            string[] tags = InternalEditorUtility.tags;
            index = 0;
            while (index < tags.Length)
            {
                if (tags[index] == tag)
                {
                    break;
                }
                index++;
            }
            ArrayUtility.Add<string>(ref tags, string.Empty);
            ArrayUtility.Add<string>(ref tags, "Add Tag...");
            DoPopup(position, controlID, index, EditorGUIUtility.TempContent(tags), style);
            return tag;
        }

        public static string TagField(Rect position, GUIContent label, string tag)
        {
            GUIStyle popup = EditorStyles.popup;
            return TagField(position, label, tag, popup);
        }

        public static string TagField(Rect position, string label, string tag, GUIStyle style)
        {
            return TagField(position, EditorGUIUtility.TempContent(label), tag, style);
        }

        public static string TagField(Rect position, GUIContent label, string tag, GUIStyle style)
        {
            int controlID = GetControlID(s_TagFieldHash, EditorGUIUtility.native, position);
            int selectedValueForControl = PopupCallbackInfo.GetSelectedValueForControl(controlID, -1);
            if (selectedValueForControl != -1)
            {
                string[] strArray = InternalEditorUtility.tags;
                if (selectedValueForControl >= strArray.Length)
                {
                    Selection.activeObject = EditorApplication.tagManager;
                }
                else
                {
                    tag = strArray[selectedValueForControl];
                }
            }
            if ((Event.current.type != EventType.MouseDown) || !position.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.Repaint)
                {
                    style.Draw(PrefixLabel(position, controlID, label), tag, false, false, false, false);
                }
                return tag;
            }
            int index = 0;
            string[] tags = InternalEditorUtility.tags;
            index = 0;
            while (index < tags.Length)
            {
                if (tags[index] == tag)
                {
                    break;
                }
                index++;
            }
            ArrayUtility.Add<string>(ref tags, string.Empty);
            ArrayUtility.Add<string>(ref tags, "Add Tag...");
            DoPopup(PrefixLabel(position, controlID, label), controlID, index, EditorGUIUtility.TempContent(tags), style);
            return tag;
        }

        internal static void TargetChoiceField(Rect position, SerializedProperty property, GUIContent label)
        {
            TargetChoiceField(position, property, label, new TargetChoiceHandler.TargetChoiceMenuFunction(TargetChoiceHandler.SetToValueOfTarget));
        }

        internal static void TargetChoiceField(Rect position, SerializedProperty property, GUIContent label, TargetChoiceHandler.TargetChoiceMenuFunction func)
        {
            BeginProperty(position, label, property);
            position = PrefixLabel(position, 0, label);
            BeginHandleMixedValueContentColor();
            if (GUI.Button(position, mixedValueContent, EditorStyles.popup))
            {
                GenericMenu menu = new GenericMenu();
                TargetChoiceHandler.AddSetToValueOfTargetMenuItems(menu, property, func);
                menu.DropDown(position);
            }
            EndHandleMixedValueContentColor();
            EndProperty();
        }

        public static string TextArea(Rect position, string text)
        {
            GUIStyle textField = EditorStyles.textField;
            return TextArea(position, text, textField);
        }

        public static string TextArea(Rect position, string text, GUIStyle style)
        {
            bool flag;
            int id = GetControlID(s_TextAreaHash, FocusType.Keyboard, position);
            text = DoTextField(s_RecycledEditor, id, IndentedRect(position), text, style, null, out flag, false, true, false);
            return text;
        }

        public static string TextField(Rect position, string text)
        {
            GUIStyle textField = EditorStyles.textField;
            return TextField(position, text, textField);
        }

        public static string TextField(Rect position, string label, string text)
        {
            GUIStyle textField = EditorStyles.textField;
            return TextField(position, label, text, textField);
        }

        public static string TextField(Rect position, string text, GUIStyle style)
        {
            bool flag;
            int id = GetControlID(s_TextFieldHash, FocusType.Keyboard, position);
            text = DoTextField(s_RecycledEditor, id, IndentedRect(position), text, style, null, out flag, false, false, false);
            return text;
        }

        public static string TextField(Rect position, GUIContent label, string text)
        {
            GUIStyle textField = EditorStyles.textField;
            return TextField(position, label, text, textField);
        }

        public static string TextField(Rect position, string label, string text, GUIStyle style)
        {
            return TextField(position, EditorGUIUtility.TempContent(label), text, style);
        }

        public static string TextField(Rect position, GUIContent label, string text, GUIStyle style)
        {
            bool flag;
            int id = GetControlID(s_TextFieldHash, FocusType.Keyboard, position);
            text = DoTextField(s_RecycledEditor, id, PrefixLabel(position, id, label), text, style, null, out flag, false, false, false);
            return text;
        }

        public static bool Toggle(Rect position, bool value)
        {
            int id = GetControlID(s_ToggleHash, EditorGUIUtility.native, position);
            return EditorGUIInternal.DoToggleForward(IndentedRect(position), id, value, GUIContent.none, EditorStyles.toggle);
        }

        public static bool Toggle(Rect position, bool value, GUIStyle style)
        {
            int id = GetControlID(s_ToggleHash, EditorGUIUtility.native, position);
            return EditorGUIInternal.DoToggleForward(position, id, value, GUIContent.none, style);
        }

        public static bool Toggle(Rect position, string label, bool value)
        {
            return Toggle(position, EditorGUIUtility.TempContent(label), value);
        }

        public static bool Toggle(Rect position, GUIContent label, bool value)
        {
            int id = GetControlID(s_ToggleHash, EditorGUIUtility.native, position);
            return EditorGUIInternal.DoToggleForward(PrefixLabel(position, id, label), id, value, GUIContent.none, EditorStyles.toggle);
        }

        public static bool Toggle(Rect position, string label, bool value, GUIStyle style)
        {
            return Toggle(position, EditorGUIUtility.TempContent(label), value, style);
        }

        public static bool Toggle(Rect position, GUIContent label, bool value, GUIStyle style)
        {
            int id = GetControlID(s_ToggleHash, EditorGUIUtility.native, position);
            return EditorGUIInternal.DoToggleForward(PrefixLabel(position, id, label), id, value, GUIContent.none, style);
        }

        internal static string ToolbarSearchField(int id, Rect position, string text, bool showWithPopupArrow)
        {
            bool flag;
            Rect rect = position;
            rect.width -= 14f;
            text = DoTextField(s_RecycledEditor, id, rect, text, !showWithPopupArrow ? EditorStyles.toolbarSearchField : EditorStyles.toolbarSearchFieldPopup, null, out flag, false, false, false);
            Rect rect2 = position;
            rect2.x += position.width - 14f;
            rect2.width = 14f;
            if (GUI.Button(rect2, GUIContent.none, !(text != string.Empty) ? EditorStyles.toolbarSearchFieldCancelButtonEmpty : EditorStyles.toolbarSearchFieldCancelButton) && (text != string.Empty))
            {
                text = string.Empty;
                GUIUtility.keyboardControl = 0;
            }
            return text;
        }

        internal static string ToolbarSearchField(Rect position, string[] searchModes, ref int searchMode, string text)
        {
            int controlID = GetControlID(s_SearchFieldHash, FocusType.Keyboard, position);
            bool showWithPopupArrow = searchModes != null;
            if (showWithPopupArrow)
            {
                searchMode = PopupCallbackInfo.GetSelectedValueForControl(controlID, searchMode);
                Rect rect = position;
                rect.width = 20f;
                if ((Event.current.type == EventType.MouseDown) && rect.Contains(Event.current.mousePosition))
                {
                    PopupCallbackInfo.instance = new PopupCallbackInfo(controlID);
                    EditorUtility.DisplayCustomMenu(position, EditorGUIUtility.TempContent(searchModes), searchMode, new EditorUtility.SelectMenuItemFunction(PopupCallbackInfo.instance.SetEnumValueDelegate), null);
                    if (s_RecycledEditor.IsEditingControl(controlID))
                    {
                        Event.current.Use();
                    }
                }
            }
            text = ToolbarSearchField(controlID, position, text, showWithPopupArrow);
            if ((showWithPopupArrow && (text == string.Empty)) && (!s_RecycledEditor.IsEditingControl(controlID) && (Event.current.type == EventType.Repaint)))
            {
                position.width -= 14f;
                BeginDisabledGroup(true);
                EditorStyles.toolbarSearchFieldPopup.Draw(position, EditorGUIUtility.TempContent(searchModes[searchMode]), controlID, false);
                EndDisabledGroup();
            }
            return text;
        }

        internal static UnityEngine.Object ValidateObjectFieldAssignment(UnityEngine.Object[] references, System.Type objType, SerializedProperty property)
        {
            if (references.Length > 0)
            {
                if (property != null)
                {
                    if (property.ValidateObjectReferenceValue(references[0]))
                    {
                        return references[0];
                    }
                }
                else
                {
                    if ((references[0].GetType() == typeof(GameObject)) && typeof(Component).IsAssignableFrom(objType))
                    {
                        references = ((GameObject) references[0]).GetComponents(typeof(Component));
                    }
                    foreach (UnityEngine.Object obj3 in references)
                    {
                        if (objType.IsAssignableFrom(obj3.GetType()))
                        {
                            return obj3;
                        }
                    }
                }
            }
            return null;
        }

        private static bool ValidTargetForIconSelection(UnityEngine.Object[] targets)
        {
            return (((targets[0] is MonoScript) || (targets[0] is GameObject)) && (targets.Length == 1));
        }

        public static Vector2 Vector2Field(Rect position, string label, Vector2 value)
        {
            s_Vector2Floats[0] = value.x;
            s_Vector2Floats[1] = value.y;
            position.height = 16f;
            GUI.Label(IndentedRect(position), label, EditorStyles.label);
            position.y += 19f;
            BeginChangeCheck();
            indentLevel++;
            MultiField(position, s_XYLabels, s_Vector2Floats);
            indentLevel--;
            if (EndChangeCheck())
            {
                value.x = s_Vector2Floats[0];
                value.y = s_Vector2Floats[1];
            }
            return value;
        }

        private static Vector3 Vector3Field(Rect position, Vector3 value)
        {
            s_Vector3Floats[0] = value.x;
            s_Vector3Floats[1] = value.y;
            s_Vector3Floats[2] = value.z;
            position.height = 16f;
            BeginChangeCheck();
            indentLevel++;
            MultiField(position, s_XYZLabels, s_Vector3Floats);
            indentLevel--;
            if (EndChangeCheck())
            {
                value.x = s_Vector3Floats[0];
                value.y = s_Vector3Floats[1];
                value.z = s_Vector3Floats[2];
            }
            return value;
        }

        public static Vector3 Vector3Field(Rect position, string label, Vector3 value)
        {
            position.height = 16f;
            GUI.Label(IndentedRect(position), label, EditorStyles.label);
            position.y += 19f;
            return Vector3Field(position, value);
        }

        private static void Vector3Field(Rect position, SerializedProperty property, GUIContent label)
        {
            int indentLevel = EditorGUI.indentLevel;
            SerializedProperty valuesIterator = property.Copy();
            valuesIterator.NextVisible(true);
            position.height = 16f;
            if (LabelHasContent(label))
            {
                GUI.Label(IndentedRect(position), label, EditorStyles.label);
                position.y += 19f;
                EditorGUI.indentLevel++;
            }
            MultiField(position, s_XYZLabels, valuesIterator);
            EditorGUI.indentLevel = indentLevel;
        }

        public static Vector4 Vector4Field(Rect position, string label, Vector4 value)
        {
            s_Vector4Floats[0] = value.x;
            s_Vector4Floats[1] = value.y;
            s_Vector4Floats[2] = value.z;
            s_Vector4Floats[3] = value.w;
            position.height = 16f;
            GUI.Label(IndentedRect(position), label, EditorStyles.label);
            position.y += 19f;
            BeginChangeCheck();
            indentLevel++;
            MultiField(position, s_XYZWLabels, s_Vector4Floats);
            indentLevel--;
            if (EndChangeCheck())
            {
                value.x = s_Vector4Floats[0];
                value.y = s_Vector4Floats[1];
                value.z = s_Vector4Floats[2];
                value.w = s_Vector4Floats[3];
            }
            return value;
        }

        internal static void VUMeterHorizontal(Rect position, float value, ref VUMeterData data)
        {
            if (Event.current.type == EventType.Repaint)
            {
                if (s_HorizontalVUTexture == null)
                {
                    s_HorizontalVUTexture = EditorGUIUtility.LoadIcon("VUMeterTextureHorizontal");
                }
                Color color = GUI.color;
                Color contentColor = GUI.contentColor;
                Color backgroundColor = GUI.backgroundColor;
                if (value < data.lastValue)
                {
                    value = Mathf.Lerp(data.lastValue, value, Time.smoothDeltaTime * 7f);
                }
                else
                {
                    value = Mathf.Lerp(value, data.lastValue, Time.smoothDeltaTime * 2f);
                    data.peakValue = value;
                    data.peakValueTime = Time.realtimeSinceStartup;
                }
                if (value > 1.111111f)
                {
                    value = 1.111111f;
                }
                if (data.peakValue > 1.111111f)
                {
                    data.peakValue = 1.111111f;
                }
                GUI.contentColor = new Color(0f, 0f, 0f, 0f);
                EditorStyles.progressBarBack.Draw(position, false, false, false, false);
                float width = (position.width * (value * 0.9f)) - 2f;
                if (width < 2f)
                {
                    width = 2f;
                }
                Rect rect = new Rect(position.x + 1f, position.y + 1f, width, position.height - 2f);
                Rect texCoords = new Rect(0f, 0f, value * 0.9f, 1f);
                GUI.DrawTextureWithTexCoords(rect, s_HorizontalVUTexture, texCoords);
                GUI.color = Color.white;
                width = (position.width * (data.peakValue * 0.9f)) - 2f;
                if (width < 2f)
                {
                    width = 2f;
                }
                rect = new Rect(position.x + width, position.y + 1f, 1f, position.height - 2f);
                if ((Time.realtimeSinceStartup - data.peakValueTime) < 1f)
                {
                    GUI.DrawTexture(rect, EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill);
                }
                GUI.backgroundColor = backgroundColor;
                GUI.color = color;
                GUI.contentColor = contentColor;
                data.lastValue = value;
            }
        }

        internal static void VUMeterVertical(Rect position, float value, ref VUMeterData data)
        {
            if (Event.current.type == EventType.Repaint)
            {
                if (s_VerticalVUTexture == null)
                {
                    s_VerticalVUTexture = EditorGUIUtility.LoadIcon("VUMeterTextureVertical");
                }
                Color color = GUI.color;
                Color contentColor = GUI.contentColor;
                Color backgroundColor = GUI.backgroundColor;
                if (value < data.lastValue)
                {
                    value = Mathf.Lerp(data.lastValue, value, Time.smoothDeltaTime * 7f);
                }
                else
                {
                    value = Mathf.Lerp(value, data.lastValue, Time.smoothDeltaTime * 2f);
                    data.peakValue = value;
                    data.peakValueTime = Time.realtimeSinceStartup;
                }
                if (value > 1.111111f)
                {
                    value = 1.111111f;
                }
                if (data.peakValue > 1.111111f)
                {
                    data.peakValue = 1.111111f;
                }
                GUI.contentColor = new Color(0f, 0f, 0f, 0f);
                EditorStyles.progressBarBack.Draw(position, false, false, false, false);
                float height = (position.height * (value * 0.9f)) - 2f;
                if (height < 2f)
                {
                    height = 2f;
                }
                Rect rect = new Rect(position.x + 1f, (position.y + position.height) - height, position.width - 2f, height);
                Rect texCoords = new Rect(0f, 0f, 1f, value * 0.9f);
                GUI.DrawTextureWithTexCoords(rect, s_VerticalVUTexture, texCoords);
                GUI.color = Color.white;
                height = (position.height * (data.peakValue * 0.9f)) - 2f;
                if (height < 2f)
                {
                    height = 2f;
                }
                rect = new Rect(position.x + 1f, (position.y + position.height) - height, position.width - 2f, 1f);
                if ((Time.realtimeSinceStartup - data.peakValueTime) < 1f)
                {
                    GUI.DrawTexture(rect, EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill);
                }
                GUI.backgroundColor = backgroundColor;
                GUI.color = color;
                GUI.contentColor = contentColor;
                data.lastValue = value;
            }
        }

        public static bool actionKey
        {
            get
            {
                if (Event.current == null)
                {
                    return false;
                }
                if (Application.platform == RuntimePlatform.OSXEditor)
                {
                    return Event.current.command;
                }
                return Event.current.control;
            }
        }

        internal static Material alphaMaterial
        {
            get
            {
                return (EditorGUIUtility.LoadRequired("Previews/PreviewAlphaMaterial.mat") as Material);
            }
        }

        internal static Material gammaCorrectMaterial
        {
            get
            {
                return (EditorGUIUtility.LoadRequired("Previews/PreviewGammaCorrectMaterial.mat") as Material);
            }
        }

        internal static Material gammaCorrectMaterialNoClip
        {
            get
            {
                return (EditorGUIUtility.LoadRequired("Previews/PreviewGammaCorrectNoClip.mat") as Material);
            }
        }

        internal static float indent
        {
            get
            {
                if (EditorGUIUtility.lookLikeInspector)
                {
                    return (indentLevel * 15f);
                }
                return ((indentLevel > 0) ? (9f + ((indentLevel - 1) * 15f)) : 0f);
            }
        }

        public static int indentLevel
        {
            get
            {
                return ms_IndentLevel;
            }
            set
            {
                ms_IndentLevel = value;
            }
        }

        internal static bool isCollectingTooltips
        {
            get
            {
                return s_CollectingToolTips;
            }
            set
            {
                s_CollectingToolTips = value;
            }
        }

        internal static Material lightmapDoubleLDRMaterial
        {
            get
            {
                return (EditorGUIUtility.LoadRequired("Previews/PreviewEncodedLightmapDoubleLDRMaterial.mat") as Material);
            }
        }

        internal static Material lightmapRGBMMaterial
        {
            get
            {
                return (EditorGUIUtility.LoadRequired("Previews/PreviewEncodedLightmapRGBMMaterial.mat") as Material);
            }
        }

        internal static GUIContent mixedValueContent
        {
            get
            {
                return s_MixedValueContent;
            }
        }

        internal static Material normalmapMaterial
        {
            get
            {
                return (EditorGUIUtility.LoadRequired("Previews/PreviewEncodedNormalsMaterial.mat") as Material);
            }
        }

        public static bool showMixedValue
        {
            get
            {
                return s_ShowMixedValue;
            }
            set
            {
                s_ShowMixedValue = value;
            }
        }

        internal sealed class DelayedTextEditor : EditorGUI.RecycledTextEditor
        {
            private int controlThatHadFocus;
            internal string controlThatHadFocusValue = string.Empty;
            private int controlThatLostFocus;
            private bool m_IgnoreBeginGUI;
            private int messageControl;
            private GUIView viewThatHadFocus;

            public void BeginGUI()
            {
                if (!this.m_IgnoreBeginGUI)
                {
                    if (GUIUtility.keyboardControl == base.controlID)
                    {
                        this.controlThatHadFocus = GUIUtility.keyboardControl;
                        this.controlThatHadFocusValue = base.content.text;
                        this.viewThatHadFocus = GUIView.current;
                    }
                    else
                    {
                        this.controlThatHadFocus = 0;
                    }
                }
            }

            public override void EndEditing()
            {
                base.EndEditing();
                this.messageControl = 0;
            }

            public void EndGUI(EventType type)
            {
                int controlThatHadFocus = 0;
                if (this.controlThatLostFocus != 0)
                {
                    this.messageControl = this.controlThatLostFocus;
                    this.controlThatLostFocus = 0;
                }
                if ((this.controlThatHadFocus != 0) && (this.controlThatHadFocus != GUIUtility.keyboardControl))
                {
                    controlThatHadFocus = this.controlThatHadFocus;
                    this.controlThatHadFocus = 0;
                }
                if (controlThatHadFocus != 0)
                {
                    this.messageControl = controlThatHadFocus;
                    this.m_IgnoreBeginGUI = true;
                    this.viewThatHadFocus.SendEvent(EditorGUIUtility.CommandEvent("DelayedControlShouldCommit"));
                    this.m_IgnoreBeginGUI = false;
                    this.messageControl = 0;
                }
            }

            public string OnGUI(int id, string value, out bool changed)
            {
                Event current = Event.current;
                if (((current.type == EventType.ExecuteCommand) && (current.commandName == "DelayedControlShouldCommit")) && (id == this.messageControl))
                {
                    changed = true;
                    current.Use();
                    return this.controlThatHadFocusValue;
                }
                changed = false;
                return value;
            }
        }

        internal delegate UnityEngine.Object ObjectFieldValidator(UnityEngine.Object[] references, System.Type objType, SerializedProperty property);

        internal sealed class PopupCallbackInfo
        {
            public static EditorGUI.PopupCallbackInfo instance;
            internal const string kPopupMenuChangedMessage = "PopupMenuChanged";
            private int m_ControlID;
            private int m_SelectedIndex;
            private GUIView m_SourceView;

            public PopupCallbackInfo(int controlID)
            {
                this.m_ControlID = controlID;
                this.m_SourceView = GUIView.current;
            }

            public static int GetSelectedValueForControl(int controlID, int selected)
            {
                Event current = Event.current;
                if ((current.type == EventType.ExecuteCommand) && (current.commandName == "PopupMenuChanged"))
                {
                    if (instance == null)
                    {
                        Debug.LogError("Popup menu has no instance");
                        return selected;
                    }
                    if (instance.m_ControlID == controlID)
                    {
                        selected = instance.m_SelectedIndex;
                        instance = null;
                        GUI.changed = true;
                        current.Use();
                    }
                }
                return selected;
            }

            internal void SetEnumValueDelegate(object userData, string[] options, int selected)
            {
                this.m_SelectedIndex = selected;
                if (this.m_SourceView != null)
                {
                    this.m_SourceView.SendEvent(EditorGUIUtility.CommandEvent("PopupMenuChanged"));
                }
            }
        }

        internal sealed class PopupMenuEvent
        {
            public string commandName;
            public GUIView receiver;

            public PopupMenuEvent(string cmd, GUIView v)
            {
                this.commandName = cmd;
                this.receiver = v;
            }

            public void SendEvent()
            {
                if (this.receiver != null)
                {
                    this.receiver.SendEvent(EditorGUIUtility.CommandEvent(this.commandName));
                }
                else
                {
                    Debug.LogError("BUG: We don't have a receiver set up, please report");
                }
            }
        }

        internal class RecycledTextEditor : TextEditor
        {
            internal static bool s_ActuallyEditing;
            internal static bool s_AllowContextCutOrPaste = true;

            public virtual void BeginEditing(int id, string text, Rect position, GUIStyle style, bool multiline, bool passwordField)
            {
                if (!this.IsEditingControl(id))
                {
                    if (EditorGUI.activeEditor != null)
                    {
                        EditorGUI.activeEditor.EndEditing();
                    }
                    EditorGUI.activeEditor = this;
                    base.controlID = id;
                    base.content.text = EditorGUI.s_OriginalText = text;
                    base.multiline = multiline;
                    base.style = style;
                    base.position = position;
                    base.isPasswordField = passwordField;
                    s_ActuallyEditing = true;
                    base.scrollOffset = Vector2.zero;
                    Undo.IncrementCurrentEventIndex();
                }
            }

            public virtual void EndEditing()
            {
                if (EditorGUI.activeEditor == this)
                {
                    EditorGUI.activeEditor = null;
                }
                base.controlID = 0;
                s_ActuallyEditing = false;
                s_AllowContextCutOrPaste = true;
                Undo.IncrementCurrentEventIndex();
            }

            internal bool IsEditingControl(int id)
            {
                return ((((GUIUtility.keyboardControl == id) && (base.controlID == id)) && (s_ActuallyEditing || !EditorGUIUtility.lookLikeInspector)) && GUIView.current.hasFocus);
            }
        }

        [StructLayout(LayoutKind.Sequential)]
        internal struct VUMeterData
        {
            public float lastValue;
            public float peakValue;
            public Texture2D texture;
            public float peakValueTime;
            public bool IsDone()
            {
                return ((this.lastValue == 0f) && (this.peakValue == 0f));
            }
        }
    }
}

